Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from torch import autocast
|
|
|
|
| 4 |
from diffusers import StableDiffusionPipeline
|
| 5 |
|
| 6 |
print("hello sylvain")
|
| 7 |
|
| 8 |
YOUR_TOKEN="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"
|
| 9 |
-
|
| 10 |
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN)
|
| 11 |
-
pipe.to(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def process(name):
|
| 14 |
return "hello " + name
|
| 15 |
|
| 16 |
-
gr.Interface(fn=
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from torch import autocast
|
| 4 |
+
from PIL import Image
|
| 5 |
from diffusers import StableDiffusionPipeline
|
| 6 |
|
| 7 |
print("hello sylvain")
|
| 8 |
|
| 9 |
YOUR_TOKEN="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"
|
| 10 |
+
device="cpu"
|
| 11 |
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN)
|
| 12 |
+
pipe.to(device)
|
| 13 |
+
|
| 14 |
+
def infer(prompt):
|
| 15 |
+
image = pipe(prompt)["sample"][0]
|
| 16 |
+
return image
|
| 17 |
|
| 18 |
def process(name):
|
| 19 |
return "hello " + name
|
| 20 |
|
| 21 |
+
gr.Interface(fn=infer, inputs="text", outputs="image").launch()
|