Ariamehr commited on
Commit
c36a591
1 Parent(s): 09cf861

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -10,6 +10,27 @@ from matplotlib.patches import Patch
10
  from PIL import Image, ImageOps
11
  from torchvision import transforms
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  # ----------------- HELPER FUNCTIONS ----------------- #
14
  os.chdir(os.path.dirname(os.path.abspath(__file__)))
15
  ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")
 
10
  from PIL import Image, ImageOps
11
  from torchvision import transforms
12
 
13
+
14
+ +import spaces
15
+ from diffusers import DiffusionPipeline
16
+
17
+ pipe = DiffusionPipeline.from_pretrained(...)
18
+ pipe.to('cuda')
19
+
20
21
+ def generate(prompt):
22
+ return pipe(prompt).images
23
+
24
+ gr.Interface(
25
+ fn=generate,
26
+ inputs=gr.Text(),
27
+ outputs=gr.Gallery(),
28
+ ).launch()
29
+
30
+ @spaces.GPU(duration=120)
31
+ def generate(prompt):
32
+ return pipe(prompt).images
33
+
34
  # ----------------- HELPER FUNCTIONS ----------------- #
35
  os.chdir(os.path.dirname(os.path.abspath(__file__)))
36
  ASSETS_DIR = os.path.join(os.path.dirname(__file__), "assets")