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

珠海企业网站建设财务管理软件

珠海企业网站建设,财务管理软件,45岁一级建造师没人要了,阿里巴巴对外贸易平台可视化latents_list如下; 可视化最后一步与标准的噪声: 能隐约看出到最后一步还是会有“马”的形状 整个代码(及可视化代码如下): ## 参考freeprompt(FPE)的代码 import os import torch import torch.nn as nn import torch.n…

可视化latents_list如下;

 可视化最后一步与标准的噪声:

能隐约看出到最后一步还是会有“马”的形状

整个代码(及可视化代码如下):

## 参考freeprompt(FPE)的代码
import os 
import torch
import torch.nn as nn
import torch.nn.functional as F
import random
from diffusers import DDIMScheduler
from typing import Optional
import numpy as np
from Freeprompt.diffuser_utils import FreePromptPipeline
from Freeprompt.freeprompt_utils import register_attention_control_new
from torchvision.utils import save_image
from torchvision.io import read_image
from Freeprompt.freeprompt import SelfAttentionControlEdit,AttentionStore, AttentionControl# Note that you may add your Hugging Face token to get access to the models
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model_path = "runwayml/stable-diffusion-v1-5"
scheduler = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", clip_sample=False, set_alpha_to_one=False)
pipe = FreePromptPipeline.from_pretrained(model_path, scheduler=scheduler).to(device)import yaml
def load_image_data(yaml_file):with open(yaml_file, 'r') as file:data = yaml.safe_load(file)return data# Note that you may add your Hugging Face token to get access to the models
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")def load_image(image_path, device):image = read_image(image_path)image = image[:3].unsqueeze_(0).float() / 127.5 - 1.  # [-1, 1]image = F.interpolate(image, (512, 512))image = image.to(device)return imageself_replace_steps = .8
NUM_DIFFUSION_STEPS = 50   # 替换40步out_dir = "examples/outputs_noise_test"# SOURCE_IMAGE_PATH = "examples/img/000141.jpg"
SOURCE_IMAGE_PATH = "/opt/data/private/ywx/EasyNLP/diffusion/FreePromptEditing/data/wild-ti2i/data/horse.png"
source_image = load_image(SOURCE_IMAGE_PATH, device)source_prompt = ""# invert the source image
start_code, latents_list = pipe.invert(source_image,source_prompt,guidance_scale=7.5,num_inference_steps=50,return_intermediates=True)
# latents_list, 从最后一个到第一个时间步的中间特征, 51个中间潜在变量# target_prompt = 'a red car'   
target_prompt = 'a photo of a pink horse in the beach'latents = torch.randn(start_code.shape, device=device)
prompts = [source_prompt, target_prompt]start_code = start_code.expand(len(prompts), -1, -1, -1)
controller = SelfAttentionControlEdit(prompts, NUM_DIFFUSION_STEPS, self_replace_steps=self_replace_steps) # 自定义模块register_attention_control_new(pipe, controller)# Note: querying the inversion intermediate features latents_list
# may obtain better reconstruction and editing results
results = pipe(prompts,latents=start_code,guidance_scale=7.5,ref_intermediate_latents=latents_list) #latents_list:51save_image(results[0], os.path.join(out_dir, str(target_prompt)+'_recon.jpg'))
save_image(results[1], os.path.join(out_dir, str(target_prompt)+'.jpg'))

 可视化:

import torch
import matplotlib.pyplot as pltnum_images = len(latents_list)
grid_size = (num_images // 5 + (num_images % 5 > 0), 5)  # 自动计算行数,确保所有图像都显示fig, axes = plt.subplots(*grid_size, figsize=(15, 15))
axes = axes.flatten()  # 将二维网格展平成一维,便于索引for i in range(num_images):latent_image = latents_list[i].squeeze().cpu().detach().numpy().transpose(1, 2, 0)axes[i].imshow(latent_image)axes[i].set_title(f"Step {i+1}")axes[i].axis('off') for j in range(num_images, len(axes)):axes[j].axis('off')plt.tight_layout() 
plt.show()

http://www.dtcms.com/wzjs/824615.html

相关文章:

  • 官方网站举例在线网页爬虫工具
  • 企业网站颜色信息手机网站模板下载
  • 现在建网站还能赚钱吗泉州网站建设科技公司
  • 宿迁网站建设价位知名个人网站
  • 网站建设案例图片科技时代
  • 音乐类网站模板网站建设规划面试技巧
  • 免费注册网站空间wordpress主题集成插件
  • 电子商务网站开发需要注意问题网站群方案
  • 如何添加网站为信任站点微信网页宣传网站怎么做的
  • 网站开发要考什么证襄阳建设网站公司
  • 建设小微公司网站需要多少钱无锡网站建设服务公司
  • 有没有电脑做兼职的网站安徽seo顾问服务
  • 福建公司网站建设定制类电商平台
  • 购物网站模板html体验好的网站
  • 青岛外贸建设网站制作小型门户网站建设方案
  • 江苏网站制作企业wordpress博客登录
  • 做房产网站需要了解什么东西做网站每年需要多少维护费
  • 制作网站的收入来源于哪里专门做物理的网站
  • 做网站的外包公司可以进吗wordpress4.7企业主题
  • 网站设计师的专业知识用ps做个人网站界面
  • 网站开发后端语言有哪些新余做网站
  • 济南最好的网站制作公司哪家好四川省建设厅资格注册中心网站
  • 做公司网站的好处为什么做的网站有的有弹窗有的没有
  • html5在线制作网站模板茶山网站建设公司
  • 大连开发区网站ps网站主页按钮怎么做
  • 兰州优秀网站推广网站建设平台加盟
  • 小说盗版网站怎么做商城平台是什么
  • 用thinkphp做的网站网站建设 万网
  • 襄阳作风建设年活动网站腾讯邮箱注册
  • 海南住房和城乡建设部网站电子商务网站建设的认识的心得