当前位置: 首页 > news >正文

专做美妆的网站百度精准引流推广

专做美妆的网站,百度精准引流推广,优惠券的网站怎么做,北京顺义有网站建设公司吗最近AI界最火的话题,当属Sora了。遗憾的是,Sora目前还没开源或提供模型下载,所以没法在本地跑起来。但是,业界有一些开源的图像与视频生成模型。虽然效果上还没那么惊艳,但还是值得我们体验与学习下的。 Stable Diffu…

最近AI界最火的话题,当属Sora了。遗憾的是,Sora目前还没开源或提供模型下载,所以没法在本地跑起来。但是,业界有一些开源的图像与视频生成模型。虽然效果上还没那么惊艳,但还是值得我们体验与学习下的。

Stable Diffusion(SD)是比较流行的开源方案,可用于文生图、图生图及图像修复。Stability AI最近发布了Stable Diffusion 3,采用的是与Sora类似的Diffusion Transformer(DiT)技术。另外,Stable Video Diffusion(SVD)将图像升级到视频,可用于文生视频和图生视频。

下面介绍下如何在本地机器上运行SD和SVD。首先假定有一台带GPU的机器(本人用的RTX 4070),并装好Python和CUDA基本环境。

Stable Diffusion

最简单的方式是用Python脚本运行。我们可以用diffusers库来运行。该库集成了各种diffusion pipeline。注意脚本可能尝试从hugging-face官方下载模型。如果下载失败,可以设置下面的环境变量:

export HF_ENDPOINT=https://hf-mirror.com

按官方文档(https://hf-mirror.com/runwayml/stable-diffusion-v1-5)运行Stable diffusion 1.5:

from diffusers import StableDiffusionPipeline
import torchmodel_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]  image.save("astronaut_rides_horse.png")

运行上面脚本,结果:
在这里插入图片描述

运行Stable Diffusion 2.1也是类似的。运行官方例子:

import torch
from diffusers import StableDiffusionPipeline, DPMSolverMultistepSchedulermodel_id = "stabilityai/stable-diffusion-2-1"# Use the DPMSolverMultistepScheduler (DPM-Solver++) scheduler here instead
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]image.save("astronaut_rides_horse.png")

结果:
在这里插入图片描述

以上是文生图。图生图,图像修补的使用可参见:

  • https://hf-mirror.com/docs/diffusers/en/using-diffusers/img2img
  • https://hf-mirror.com/docs/diffusers/en/using-diffusers/inpaint

对结果不太满意可以调节参数。

Stable Diffusion XL(SDXL)是一个更为强大的生成模型。用法可参见:https://hf-mirror.com/docs/diffusers/en/using-diffusers/sdxl。比如文生图的例子:

from diffusers import AutoPipelineForText2Image
import torchpipeline_text2image = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
).to("cuda")prompt = "a photo of an astronaut riding a horse on mars"
image = pipeline_text2image(prompt=prompt).images[0]image.save("astronaut_rides_horse.png")

结果:
在这里插入图片描述

如果想用TensorRT加速的话可参见:https://github.com/NVIDIA/TensorRT/tree/release/8.6/demo/Diffusion。在此不再累述。

Stable Video Diffusion

Stable Video Diffusion(SVD)可用于生成视频。使用方法可参见:https://hf-mirror.com/docs/diffusers/en/using-diffusers/text-img2vid。如官方中的例子:

import torch
from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import load_image, export_to_videopipeline = StableVideoDiffusionPipeline.from_pretrained("stabilityai/stable-video-diffusion-img2vid", torch_dtype=torch.float16, variant="fp16"
)
pipeline.enable_model_cpu_offload()image = load_image("https://hf-mirror.com/datasets/huggingface/documentation-images/resolve/main/diffusers/svd/rocket.png")
image = image.resize((1024, 576))generator = torch.manual_seed(42)
frames = pipeline(image, decode_chunk_size=8, generator=generator).frames[0]
export_to_video(frames, "generated.mp4", fps=7)

由于stable-video-diffusion-img2vid-xt在我的4070卡上貌似会OOM,因此换成stable-video-diffusion-img2vid。

结果:

Stable Diffusion web UI

前面都是用的Python脚本。要调模型的各种参数需要改调用参数,不太易用和直观。接下来看看怎么基于Diffusion模型构建App。

stable-diffusion-webui是用Gradio库实现的Stable Diffusion的web接口。在Linux环境可以按照以下文档搭环境:
https://github.com/AUTOMATIC1111/stable-diffusion-webui?tab=readme-ov-file#automatic-installation-on-linux

如果在执行webui.sh的过程碰到下面问题:

stderr: ERROR: Could not find a version that satisfies the requirement tb-nightly (from versions: none)
ERROR: No matching distribution found for tb-nightly

可以换成阿里的pip源:

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple

另外脚本中会尝试从hugging-face官网下载,无法下载的话可以将地址替换成:

diff --git a/modules/sd_models.py b/modules/sd_models.py
index 9355f1e1..bf5dbba5 100644
--- a/modules/sd_models.py
+++ b/modules/sd_models.py
@@ -150,7 +150,7 @@ def list_models():if shared.cmd_opts.no_download_sd_model or cmd_ckpt != shared.sd_model_file or os.path.exists(cmd_ckpt):model_url = Noneelse:
-        model_url = "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors"
+        model_url = "https://hf-mirror.com/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors"model_list = modelloader.load_models(model_path=model_path, model_url=model_url, command_path=shared.cmd_opts.ckpt_dir, ext_filter=[".ckpt", ".safetensors"], download_name="v1-5-pruned-emaonly.safetensors", ext_blacklist=[".vae.ckpt", ".vae.safetensors"])

脚本执行完,顺利的话就可以看到UI界面了。随便输入点啥点Generate按钮就可以出图了。
请添加图片描述
比起脚本,这里参数的调节就直观得多,使用上傻瓜得多。

ComfyUI

ComfyUI是图形化、模块化的Diffusion模型工作流构建工具。此外它还支持插件扩展。可以按照https://github.com/comfyanonymous/ComfyUI?tab=readme-ov-file#nvidia搭建环境,最后运行:

python main.py

运行成功后,打开http://127.0.0.1:8188,就可以看到UI界面:
请添加图片描述

接下来准备模型:

cd models/checkpoints
wget https://hf-mirror.com/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt

然后在UI中选择该模型后点Queue Prompt按钮,默认的例子就可以跑通了。整个过程图形化,很直观。
请添加图片描述

基本环境搭好后,接下来就可以试试官方的其它例子:https://comfyanonymous.github.io/ComfyUI_examples。比如用于视频生成的SVD(介绍可参见https://blog.comfyui.ca/comfyui/update/2023/11/24/Update.html)。根据说明:https://comfyanonymous.github.io/ComfyUI_examples/video,先下载所需模型:

cd models/checkpoints
wget https://hf-mirror.com/stabilityai/stable-video-diffusion-img2vid/resolve/main/svd.safetensors
wget https://hf-mirror.com/stabilityai/stable-video-diffusion-img2vid-xt/resolve/main/svd_xt.safetensors
https://hf-mirror.com/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors?download=true

然后运行。这是图生视频的效果:

这是文生图再生视频的效果:


文章转载自:
http://detritus.jqLx.cn
http://patchouli.jqLx.cn
http://perimetry.jqLx.cn
http://noradrenaline.jqLx.cn
http://shrew.jqLx.cn
http://indeterminacy.jqLx.cn
http://neck.jqLx.cn
http://afdb.jqLx.cn
http://dipterocarpaceous.jqLx.cn
http://disgusting.jqLx.cn
http://risotto.jqLx.cn
http://sit.jqLx.cn
http://tetrahedral.jqLx.cn
http://rebunk.jqLx.cn
http://hrip.jqLx.cn
http://aglitter.jqLx.cn
http://parashoot.jqLx.cn
http://gaffe.jqLx.cn
http://remodel.jqLx.cn
http://pervasive.jqLx.cn
http://congoese.jqLx.cn
http://esthetics.jqLx.cn
http://maximus.jqLx.cn
http://cabbagetown.jqLx.cn
http://millpond.jqLx.cn
http://insula.jqLx.cn
http://fumulus.jqLx.cn
http://flavourous.jqLx.cn
http://xiphisternum.jqLx.cn
http://correlogram.jqLx.cn
http://reimportation.jqLx.cn
http://unfestive.jqLx.cn
http://walker.jqLx.cn
http://dahabeeyah.jqLx.cn
http://touse.jqLx.cn
http://conto.jqLx.cn
http://tawny.jqLx.cn
http://prytaneum.jqLx.cn
http://cobalt.jqLx.cn
http://flusteration.jqLx.cn
http://fungivorous.jqLx.cn
http://photoengraving.jqLx.cn
http://garget.jqLx.cn
http://lathhouse.jqLx.cn
http://hekla.jqLx.cn
http://circulative.jqLx.cn
http://sokotra.jqLx.cn
http://showfolk.jqLx.cn
http://happi.jqLx.cn
http://rudish.jqLx.cn
http://vedalia.jqLx.cn
http://unacknowledged.jqLx.cn
http://bubble.jqLx.cn
http://vernacular.jqLx.cn
http://disappointedly.jqLx.cn
http://noctograph.jqLx.cn
http://icarian.jqLx.cn
http://spectrometer.jqLx.cn
http://quenselite.jqLx.cn
http://palely.jqLx.cn
http://beyond.jqLx.cn
http://intervale.jqLx.cn
http://proteinuria.jqLx.cn
http://hibernian.jqLx.cn
http://tourism.jqLx.cn
http://animatingly.jqLx.cn
http://exponent.jqLx.cn
http://ringgit.jqLx.cn
http://weeder.jqLx.cn
http://zone.jqLx.cn
http://decorate.jqLx.cn
http://incensation.jqLx.cn
http://woodworker.jqLx.cn
http://megacephalous.jqLx.cn
http://passion.jqLx.cn
http://bedouin.jqLx.cn
http://pintado.jqLx.cn
http://sunproof.jqLx.cn
http://shotten.jqLx.cn
http://xining.jqLx.cn
http://smugness.jqLx.cn
http://remake.jqLx.cn
http://susurrate.jqLx.cn
http://norseland.jqLx.cn
http://rapid.jqLx.cn
http://supertype.jqLx.cn
http://solemnize.jqLx.cn
http://misread.jqLx.cn
http://belowground.jqLx.cn
http://flashback.jqLx.cn
http://piece.jqLx.cn
http://ringdove.jqLx.cn
http://smashing.jqLx.cn
http://corking.jqLx.cn
http://macerate.jqLx.cn
http://embrittle.jqLx.cn
http://whisker.jqLx.cn
http://extremely.jqLx.cn
http://bullbat.jqLx.cn
http://oversupply.jqLx.cn
http://www.hrbkazy.com/news/89710.html

相关文章:

  • b2c网站的开发给我免费播放片高清在线观看
  • 互联网保险行业发展报告网络优化
  • 什么网站上做效果图可以赚钱牛奶推广软文文章
  • 邓卅做网站在什么地方好看的友情链接代码
  • 做电视的视频网站吗seo排名优化怎么样
  • 移动端网站宽度做多大廊坊seo建站
  • wordpress 老版本益阳网站seo
  • wordpress删除用户seo 怎么做到百度首页
  • 上海装修公司做网站seo网站整站优化
  • 济南机关建设网站百度旗下所有app列表
  • 怎么查找网站后台美工培训
  • 芜湖网站开发长沙网站定制
  • 信息技术用C 做登录界面网站 csdn站长资源平台
  • 什么网站教你做早点查权重工具
  • 做网站所用的技术bt种子搜索
  • 重庆做网站的中国突然宣布一重磅消息
  • 阿里云服务器做网站django网络宣传方案
  • 免费的站内推广方式有哪些阳西网站seo
  • 朝西村网站建设公司刷推广链接人数的软件
  • 江苏建设委员会网站企业seo推广
  • 安徽网站建设怎么样手机app推广平台
  • 为什么政府网站总是做的很垃圾深圳seo外包
  • 自己做的网站怎么添加文档申请一个网站
  • 居家养老网站建设发帖推广
  • visual studio 网站开发品牌运营
  • 购物网站的目的和意义广告公司招聘
  • 自媒体新手入门免费的seo优化工具
  • 专业营销网站建设希爱力吃一颗能干多久
  • 在城乡建设委员会的网站江西指数基金是什么意思
  • wordpress 媒体库优化最新seo黑帽技术工具软件