Spaces:
Runtime error
Runtime error
Commit
·
e3f67bb
1
Parent(s):
2d2f60b
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,23 @@ import transformers
|
|
2 |
import gradio as gr
|
3 |
import datasets
|
4 |
import torch
|
|
|
5 |
from diffusers import StableDiffusionPipeline
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
import datasets
|
4 |
import torch
|
5 |
+
import os
|
6 |
from diffusers import StableDiffusionPipeline
|
7 |
+
|
8 |
+
# Initialise the token
|
9 |
+
HF_TOKEN = os.getenv('HF_TOKEN')
|
10 |
+
|
11 |
+
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=HF_TOKEN)
|
12 |
+
device = torch.device('coda' if torch.cuda.is_available() else 'cpu')
|
13 |
+
pipe = pipe.to(device)
|
14 |
+
|
15 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, 'crowdsourced-movieposter-demo')
|
16 |
+
|
17 |
+
gr.Interface(
|
18 |
+
fn=generate,
|
19 |
+
inputs=[gr.Textbox(label='Celebrity Name'), gr.Dropdown(['Mission Impossible', 'Avatar', 'Abyss', 'TOO OLD TO DIE YOUNG', 'The Last Dual','The beginning of everything'], label='Movie'), gr.Slider(label='Image Accuracy', minimum=7.5, maximum=20, value=12)],
|
20 |
+
outputs=gr.Image(type='pil') ,
|
21 |
+
allow_flagging="manual",
|
22 |
+
flagging_options=["No Image", "good", "bad"],
|
23 |
+
flagging_callback=hf_writer
|
24 |
+
).launch()
|