verymehari commited on
Commit
06895e6
·
verified ·
1 Parent(s): 105fa40

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +13 -1
  2. requirements.txt +2 -1
app.py CHANGED
@@ -8,6 +8,17 @@ from pathlib import Path
8
 
9
  import gradio as gr
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  ROOT = Path(__file__).resolve().parent
12
  sys.path.insert(0, str(ROOT))
13
 
@@ -79,6 +90,7 @@ def render_lineage(provenance: dict) -> str:
79
  """
80
 
81
 
 
82
  def generate(lora_a: str, lora_b: str, blend_a: int, prompt: str, seed: int, size: int):
83
  if not prompt.strip():
84
  raise gr.Error("Give the image a prompt first.")
@@ -119,7 +131,7 @@ def build_demo():
119
  blend = gr.Slider(0, 100, value=100, step=1, label="Blend: A % / B %")
120
  prompt = gr.Textbox(label="Describe the imagined instrument image", value="a musician holding a newly invented bowl-shaped string instrument in a small warm room", lines=3)
121
  seed = gr.Number(label="Seed", value=42, precision=0)
122
- size = gr.Dropdown(label="Image size", choices=[512, 768, 1024], value=768)
123
  btn = gr.Button("Generate with live LoRA", variant="primary")
124
  with gr.Column(scale=2):
125
  output_image = gr.Image(label="Generated image", type="pil")
 
8
 
9
  import gradio as gr
10
 
11
+ try:
12
+ import spaces
13
+ except Exception: # local dev outside HF Spaces
14
+ class _SpacesShim:
15
+ @staticmethod
16
+ def GPU(*args, **kwargs):
17
+ def deco(fn):
18
+ return fn
19
+ return deco
20
+ spaces = _SpacesShim()
21
+
22
  ROOT = Path(__file__).resolve().parent
23
  sys.path.insert(0, str(ROOT))
24
 
 
90
  """
91
 
92
 
93
+ @spaces.GPU(duration=180)
94
  def generate(lora_a: str, lora_b: str, blend_a: int, prompt: str, seed: int, size: int):
95
  if not prompt.strip():
96
  raise gr.Error("Give the image a prompt first.")
 
131
  blend = gr.Slider(0, 100, value=100, step=1, label="Blend: A % / B %")
132
  prompt = gr.Textbox(label="Describe the imagined instrument image", value="a musician holding a newly invented bowl-shaped string instrument in a small warm room", lines=3)
133
  seed = gr.Number(label="Seed", value=42, precision=0)
134
+ size = gr.Slider(512, 1024, value=768, step=256, label="Image size")
135
  btn = gr.Button("Generate with live LoRA", variant="primary")
136
  with gr.Column(scale=2):
137
  output_image = gr.Image(label="Generated image", type="pil")
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- gradio>=5.0
2
  pydantic>=2.0
3
  PyYAML>=6.0
4
  Pillow>=10.0
@@ -6,6 +6,7 @@ requests>=2.31
6
  huggingface_hub>=0.26,<1.0
7
  peft>=0.14
8
  accelerate>=1.0
 
9
  torch
10
  diffusers @ git+https://github.com/huggingface/diffusers.git
11
  transformers
 
1
+ gradio==5.49.1
2
  pydantic>=2.0
3
  PyYAML>=6.0
4
  Pillow>=10.0
 
6
  huggingface_hub>=0.26,<1.0
7
  peft>=0.14
8
  accelerate>=1.0
9
+ spaces
10
  torch
11
  diffusers @ git+https://github.com/huggingface/diffusers.git
12
  transformers