Update app.py
Browse files
app.py
CHANGED
@@ -1,43 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
-
#import torch
|
3 |
-
#from torch import autocast // only for GPU
|
4 |
-
|
5 |
-
from PIL import Image
|
6 |
-
|
7 |
-
import os
|
8 |
-
MY_SECRET_TOKEN=os.environ.get('HF_TOKEN_SD')
|
9 |
-
|
10 |
from diffusers import StableDiffusionPipeline
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
images.append(safe_image)
|
33 |
-
else:
|
34 |
-
images.append(image)
|
35 |
-
|
36 |
-
return images
|
37 |
-
|
38 |
-
print("Great sylvain ! Everything is working fine !")
|
39 |
-
|
40 |
-
title="Stable Diffusion CPU"
|
41 |
-
description="Stable Diffusion example using CPU and HF token. <br />Warning: Slow process... ~5/10 min inference time. <b>NSFW filter enabled.</b>"
|
42 |
-
|
43 |
-
gr.Interface(fn=infer, inputs="text", outputs=gallery,title=title,description=description).queue(max_size=10).launch(enable_queue=True)
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
pipe = StableDiffusionPipeline.from_pretrained("MohamedRashad/diffusion_fashion", torch_dtype=torch.float32)
|
6 |
+
pipe.to("cpu")
|
7 |
+
|
8 |
+
def generate_image(text):
|
9 |
+
images = pipe(text).images
|
10 |
+
image = images[0]
|
11 |
+
return image
|
12 |
+
|
13 |
+
diffusion_interface = gr.Interface(
|
14 |
+
generate_image,
|
15 |
+
gr.Textbox(lines=1, label="Input"),
|
16 |
+
gr.Image(type="pil", label="Output"),
|
17 |
+
title="Diffusion4Fashion: Generate cool clothes!",
|
18 |
+
description="<center><p>Enter a description about a piece of cloth and the model will generate an image.</p></center>",
|
19 |
+
examples=["A photo of a dress, made in 2019, color is Red, Casual usage, Women's cloth, something for the summer season, on white background"],
|
20 |
+
cache_examples=True,
|
21 |
+
)
|
22 |
+
|
23 |
+
diffusion_interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|