Hzqhssn commited on
Commit
1c4b8e5
·
1 Parent(s): 489b056

initial commit

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. app.py +33 -0
  3. astronaut_rides_horse.png +0 -0
  4. requirements.txt +10 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Virtual environments
2
+ venv
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import StableDiffusionPipeline
3
+ import gradio as gr
4
+
5
+ model_id = "CompVis/stable-diffusion-v1-4"
6
+ device = "cuda"
7
+
8
+
9
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
10
+ pipe = pipe.to(device)
11
+
12
+
13
+
14
+ # Prediction function
15
+ def generate_image(prompt):
16
+
17
+ image = pipe(prompt).images[0]
18
+
19
+ return image
20
+
21
+
22
+
23
+ demo = gr.Interface(
24
+ fn=generate_image,
25
+ inputs=gr.Textbox(label="Enter Prompt"),
26
+ outputs=gr.Image(label="Results"),
27
+ title="generate Images",
28
+ allow_flagging="never"
29
+ )
30
+
31
+
32
+ # Launch the interface
33
+ demo.launch()
astronaut_rides_horse.png ADDED
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ transformers
2
+ torch
3
+ requests
4
+ Pillow
5
+ open_clip_torch
6
+ diffusers
7
+ transformers
8
+ scipy
9
+ # This is only needed for local deployment
10
+ gradio