CantonMonkey commited on
Commit
b49d3bd
·
1 Parent(s): 8523f93

test ControlNet with a random generated dummy img

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -52,6 +52,7 @@ import torch
52
  from diffusers import StableDiffusionPipeline, ControlNetModel, StableDiffusionControlNetPipeline
53
  from PIL import Image
54
  import gradio as gr
 
55
 
56
  # 自动选择设备
57
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -74,7 +75,8 @@ pipe.enable_attention_slicing()
74
 
75
  # 文生图生成函数
76
  def generate_image(prompt, num_steps=20, height=256, width=256):
77
- image = pipe(prompt, num_inference_steps=num_steps, height=height, width=width).images[0]
 
78
  return image
79
 
80
  # Gradio 界面
 
52
  from diffusers import StableDiffusionPipeline, ControlNetModel, StableDiffusionControlNetPipeline
53
  from PIL import Image
54
  import gradio as gr
55
+ import numpy as np
56
 
57
  # 自动选择设备
58
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
75
 
76
  # 文生图生成函数
77
  def generate_image(prompt, num_steps=20, height=256, width=256):
78
+ dummy_image = Image.fromarray(np.zeros((height, width, 3), dtype=np.uint8))
79
+ image = pipe(prompt, num_inference_steps=num_steps, height=height, width=width,image=dummy_image).images[0]
80
  return image
81
 
82
  # Gradio 界面