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

redis网站开发教程网络工程师面试题

redis网站开发教程,网络工程师面试题,自己公司的网站怎么编辑,化妆品网站源码asp最近AI界最火的话题#xff0c;当属Sora了。遗憾的是#xff0c;Sora目前还没开源或提供模型下载#xff0c;所以没法在本地跑起来。但是#xff0c;业界有一些开源的图像与视频生成模型。虽然效果上还没那么惊艳#xff0c;但还是值得我们体验与学习下的。 Stable Diffu…最近AI界最火的话题当属Sora了。遗憾的是Sora目前还没开源或提供模型下载所以没法在本地跑起来。但是业界有一些开源的图像与视频生成模型。虽然效果上还没那么惊艳但还是值得我们体验与学习下的。 Stable DiffusionSD是比较流行的开源方案可用于文生图、图生图及图像修复。Stability AI最近发布了Stable Diffusion 3采用的是与Sora类似的Diffusion TransformerDiT技术。另外Stable Video DiffusionSVD将图像升级到视频可用于文生视频和图生视频。 下面介绍下如何在本地机器上运行SD和SVD。首先假定有一台带GPU的机器本人用的RTX 4070并装好Python和CUDA基本环境。 Stable Diffusion 最简单的方式是用Python脚本运行。我们可以用diffusers库来运行。该库集成了各种diffusion pipeline。注意脚本可能尝试从hugging-face官方下载模型。如果下载失败可以设置下面的环境变量 export HF_ENDPOINThttps://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_dtypetorch.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_dtypetorch.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/img2imghttps://hf-mirror.com/docs/diffusers/en/using-diffusers/inpaint 对结果不太满意可以调节参数。 Stable Diffusion XLSDXL是一个更为强大的生成模型。用法可参见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_dtypetorch.float16, variantfp16, use_safetensorsTrue ).to(cuda)prompt a photo of an astronaut riding a horse on mars image pipeline_text2image(promptprompt).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 DiffusionSVD可用于生成视频。使用方法可参见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_dtypetorch.float16, variantfp16 ) 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_size8, generatorgenerator).frames[0] export_to_video(frames, generated.mp4, fps7)由于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?tabreadme-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.pyb/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.safetensorsmodel_url https://hf-mirror.com/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensorsmodel_list modelloader.load_models(model_pathmodel_path, model_urlmodel_url, command_pathshared.cmd_opts.ckpt_dir, ext_filter[.ckpt, .safetensors], download_namev1-5-pruned-emaonly.safetensors, ext_blacklist[.vae.ckpt, .vae.safetensors])脚本执行完顺利的话就可以看到UI界面了。随便输入点啥点Generate按钮就可以出图了。 比起脚本这里参数的调节就直观得多使用上傻瓜得多。 ComfyUI ComfyUI是图形化、模块化的Diffusion模型工作流构建工具。此外它还支持插件扩展。可以按照https://github.com/comfyanonymous/ComfyUI?tabreadme-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?downloadtrue然后运行。这是图生视频的效果 这是文生图再生视频的效果
http://www.hkea.cn/news/14336408/

相关文章:

  • 营销型企业网站优化维启网站建设
  • 江苏省建设工程质量监督站网站泉州pc网站开发
  • 昆明企业网站建设公司wordpress主题模板中国
  • 专业做合同的网站比较好的建站公司
  • 做淘宝客个人网站帝国网站数据库配置文件
  • 一次性付费做网站建设银行属于哪里
  • 免费软件制作网站模板我想做百度推广
  • 湘潭seo网站优化网站建设基本要素
  • 推荐网站建设服务话术网页设计展示图
  • 盘锦网站建设 盘锦建站推广 盘锦建站无锡网页网站制作公司
  • 嘉兴建设网站的招生网站开发的背景
  • 交流稿 网站建设wordpress钉钉登录
  • 网站收费系统平台vi设计应用部分有哪些
  • 电子商务网站的网络营销策略分析玉环做网站
  • 企业每月报账在哪个网站做网站开发脚本解析器
  • 欧美色影网站ui界面设计案例
  • 甘肃省住房和城乡建设厅安置局网站广州建站网站
  • 十堰网站设计公司网站页面效果图怎么做的
  • 哪个网站做餐饮推广最好orion 响应式单页 wordpress主题
  • 群晖nas做网站c 做网站好嘛
  • 长沙网站制作公司地址白狐网站建设
  • 济宁市住房和城乡建设厅网站织梦技术个人网站模板
  • 做app公司一般叫什么公司seo诊断分析报告
  • 西安的商城网站新闻发布网站模板
  • 铁岭做网站包括哪些网站维护托管公司
  • 网站备案更改吗推广普通话手抄报图片
  • 苏州网站建设推广咨询平台内容管理系统WordPress
  • 做mod的网站哈尔滨网站建设一薇ls15227
  • 一级a做爰片阿v祥仔网站开发网站通过第三方微信认证登录开发费用
  • 网站建设淘宝网站为什么上传不了图片