Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
#from torch import autocast // only for GPU
|
4 |
|
5 |
from PIL import Image
|
@@ -12,7 +12,7 @@ MY_SECRET_TOKEN=os.environ.get('HF_TOKEN_SD')
|
|
12 |
from diffusers import StableDiffusionImg2ImgPipeline
|
13 |
|
14 |
def empty_checker(images, **kwargs): return images, False
|
15 |
-
print("
|
16 |
|
17 |
YOUR_TOKEN=MY_SECRET_TOKEN
|
18 |
|
@@ -35,21 +35,26 @@ def resize(value,img):
|
|
35 |
return img
|
36 |
|
37 |
|
38 |
-
def infer(source_img, prompt):
|
39 |
|
40 |
source_image = resize(512, source_img)
|
41 |
source_image.save('source.png')
|
42 |
-
images_list = img_pipe([prompt] * 1,
|
43 |
images = []
|
44 |
|
45 |
for i, image in enumerate(images_list["images"]):
|
46 |
images.append(image)
|
47 |
return images
|
48 |
|
49 |
-
print("
|
50 |
|
51 |
title="Marco Generation Sketch"
|
52 |
-
description="Draw and use 'mkmk woman' to get Marco pics. <br />Warning: Slow process... about 10 min inference time
|
53 |
|
54 |
|
55 |
-
gr.Interface(fn=infer, inputs=[source_img,
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
#from torch import autocast // only for GPU
|
4 |
|
5 |
from PIL import Image
|
|
|
12 |
from diffusers import StableDiffusionImg2ImgPipeline
|
13 |
|
14 |
def empty_checker(images, **kwargs): return images, False
|
15 |
+
print("hello")
|
16 |
|
17 |
YOUR_TOKEN=MY_SECRET_TOKEN
|
18 |
|
|
|
35 |
return img
|
36 |
|
37 |
|
38 |
+
def infer(source_img, prompt, guide, steps, seed, strength):
|
39 |
|
40 |
source_image = resize(512, source_img)
|
41 |
source_image.save('source.png')
|
42 |
+
images_list = img_pipe([prompt] * 1, init_image=source_image, strength=strength, guidance_scale=guide, num_inference_steps=steps)
|
43 |
images = []
|
44 |
|
45 |
for i, image in enumerate(images_list["images"]):
|
46 |
images.append(image)
|
47 |
return images
|
48 |
|
49 |
+
print("done")
|
50 |
|
51 |
title="Marco Generation Sketch"
|
52 |
+
description="<p style='text-align: center;'>Draw and use 'mkmk woman' to get Marco pics. <br />Warning: Slow process... about 10 min inference time.</p>"
|
53 |
|
54 |
|
55 |
+
gr.Interface(fn=infer, inputs=[source_img,
|
56 |
+
"text",
|
57 |
+
gr.Slider(2, 15, value = 7, label = 'Guidence Scale'),
|
58 |
+
gr.Slider(10, 50, value = 25, step = 1, label = 'Number of Iterations'),
|
59 |
+
gr.Slider(label = "Seed", minimum = 0, maximum = 2147483647, step = 1, randomize = True),
|
60 |
+
gr.Slider(label='Strength', minimum = 0, maximum = 1, step = .05, value = .75)], outputs=gallery,title=title,description=description).queue(max_size=100).launch(enable_queue=True)
|