Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,32 +2,28 @@ import gradio as gr
|
|
2 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
3 |
import torch
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def imagen(inputs):
|
7 |
|
8 |
prompt = inputs
|
9 |
negative_prompt = 'pixelated, distorted'
|
10 |
|
11 |
-
model_id = "Fazzie/PokemonGAI"
|
12 |
-
|
13 |
-
|
14 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
15 |
-
if torch.cuda.is_available():
|
16 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, revision="fp16")
|
17 |
-
else:
|
18 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
19 |
-
|
20 |
-
print("load model successfully!")
|
21 |
-
pipe = pipe.to(device)
|
22 |
-
|
23 |
-
# pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
24 |
-
|
25 |
print("start inference")
|
26 |
image = pipe(prompt=inputs, negative_prompt=negative_prompt).images[0]
|
27 |
print("finish inference!")
|
28 |
return image
|
29 |
-
|
30 |
demo = gr.Interface(fn=imagen, inputs=[gr.Textbox(label = 'Prompt')], outputs="image")
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
# gr.Interface.load("models/Fazzie/PokemonGAI").launch()
|
|
|
2 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
3 |
import torch
|
4 |
|
5 |
+
model_id = "Fazzie/PokemonGAI"
|
6 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
8 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
9 |
+
print("load model successfully!")
|
10 |
+
pipe = pipe.to(device)
|
11 |
|
12 |
def imagen(inputs):
|
13 |
|
14 |
prompt = inputs
|
15 |
negative_prompt = 'pixelated, distorted'
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
print("start inference")
|
18 |
image = pipe(prompt=inputs, negative_prompt=negative_prompt).images[0]
|
19 |
print("finish inference!")
|
20 |
return image
|
21 |
+
|
22 |
demo = gr.Interface(fn=imagen, inputs=[gr.Textbox(label = 'Prompt')], outputs="image")
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
demo.launch()
|
26 |
+
|
27 |
+
image.save("1.png")
|
28 |
|
29 |
# gr.Interface.load("models/Fazzie/PokemonGAI").launch()
|