jepz commited on
Commit
dd3e151
·
verified ·
1 Parent(s): 28e5d96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -34,15 +34,10 @@ MAX_IMAGE_SIZE = 1024
34
 
35
  def generate_image(uploaded_image):
36
  # Open the uploaded image
37
- image = Image.open(uploaded_image)
38
-
39
- # Run the image through the Stable Diffusion pipeline
40
- with torch.no_grad():
41
- output = pipe(image, guidance_scale=7.5)["sample"][0]
42
-
43
  return output
44
 
45
- def infer(base_img, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, strength):
46
 
47
  if randomize_seed:
48
  seed = random.randint(0, MAX_SEED)
@@ -50,7 +45,7 @@ def infer(base_img, prompt, negative_prompt, seed, randomize_seed, width, height
50
  generator = torch.Generator().manual_seed(seed)
51
 
52
  image = pipe(
53
- image = base_img,
54
  prompt = prompt,
55
  negative_prompt = negative_prompt,
56
  guidance_scale = guidance_scale,
@@ -90,8 +85,9 @@ with gr.Blocks(css=css) as demo:
90
 
91
 
92
  with gr.Row():
93
- base_img = gr.Interface(fn=generate_image, inputs=gr.Image(type="pil"), outputs=gr.Image(type="pil"))
94
-
 
95
  with gr.Row():
96
 
97
  prompt = gr.Text(
@@ -168,7 +164,7 @@ with gr.Blocks(css=css) as demo:
168
 
169
  run_button.click(
170
  fn = infer,
171
- inputs = [base_img, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, strength],
172
  outputs = [result]
173
  )
174
 
 
34
 
35
  def generate_image(uploaded_image):
36
  # Open the uploaded image
37
+ image = Image.open(uploaded_image)
 
 
 
 
 
38
  return output
39
 
40
+ def infer(image, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, strength):
41
 
42
  if randomize_seed:
43
  seed = random.randint(0, MAX_SEED)
 
45
  generator = torch.Generator().manual_seed(seed)
46
 
47
  image = pipe(
48
+ image = image,
49
  prompt = prompt,
50
  negative_prompt = negative_prompt,
51
  guidance_scale = guidance_scale,
 
85
 
86
 
87
  with gr.Row():
88
+ image = gr.Interface(fn=generate_image, inputs=gr.Image(), "image")
89
+
90
+ gr.Interface(sepia, gr.Image(), "image")
91
  with gr.Row():
92
 
93
  prompt = gr.Text(
 
164
 
165
  run_button.click(
166
  fn = infer,
167
+ inputs = [image, prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, strength],
168
  outputs = [result]
169
  )
170