jerukperas commited on
Commit
0cb616f
·
verified ·
1 Parent(s): eac98fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -43
app.py CHANGED
@@ -1,9 +1,8 @@
1
- import spaces # type: ignore
2
  import os
3
- import time # noqa: F401
4
  import uuid
5
  from PIL import Image
6
- import gradio as gr # type: ignore
7
  import numpy as np
8
  import random
9
  import torch
@@ -62,9 +61,8 @@ def infer(
62
 
63
 
64
  examples = [
65
- "a tiny astronaut hatching from an egg on the moon",
66
- "a cat holding a sign that says hello world",
67
- "an anime illustration of a wiener schnitzel",
68
  ]
69
 
70
  css = """
@@ -82,13 +80,14 @@ with gr.Blocks(css=css) as demo:
82
  """)
83
 
84
  with gr.Row(equal_height=False):
85
- prompt = gr.TextArea(
86
- label="Prompt",
87
- show_label=False,
88
- lines=3,
89
- placeholder="Enter your prompt",
90
- container=False,
91
- )
 
92
 
93
  run_button = gr.Button("Run", variant="primary", scale=0)
94
 
@@ -147,17 +146,20 @@ with gr.Blocks(css=css) as demo:
147
  value=28,
148
  )
149
 
150
- # gr.Examples(
151
- # examples=examples,
152
- # fn=infer,
153
- # inputs=[prompt],
154
- # outputs=[result, seed],
155
- # cache_examples="lazy",
156
- # visible=False,
157
- # )
158
-
159
- run_button.click(fn=lambda: gr.update(visible=False),inputs=None, outputs=download)
160
-
 
 
 
161
  gr.on(
162
  triggers=[run_button.click, prompt.submit],
163
  fn=infer,
@@ -173,25 +175,6 @@ with gr.Blocks(css=css) as demo:
173
  outputs=[result, download, seed],
174
  )
175
 
176
- # def delete_packed_tensors(
177
- # startup_time: int = time.time_ns(),
178
- # zerogpu_offload_dir: str = "/home/user/.zerogpu/tensors",
179
- # ) -> None:
180
- # entries = os.scandir(zerogpu_offload_dir)
181
- # for entry in entries:
182
- # print(f"Found entry {entry.path}")
183
- # if entry.stat().st_atime_ns < startup_time:
184
- # try:
185
- # file_path = entry.path
186
- # os.remove(file_path)
187
- # print(f"File deleted successfully: {file_path}")
188
- # except FileNotFoundError:
189
- # print(f"File not found: {file_path}")
190
- # except OSError as e:
191
- # print(f"Error deleting file: {e}")
192
-
193
-
194
  if __name__ == "__main__":
195
- # delete_packed_tensors()
196
  os.makedirs("images", exist_ok=True)
197
  demo.launch()
 
1
+ import spaces # type: ignore
2
  import os
 
3
  import uuid
4
  from PIL import Image
5
+ import gradio as gr
6
  import numpy as np
7
  import random
8
  import torch
 
61
 
62
 
63
  examples = [
64
+ "a cat holding a sign that says flux.1 is great",
65
+ "an old man holding a sign that says Increase Zero-GPU Limit",
 
66
  ]
67
 
68
  css = """
 
80
  """)
81
 
82
  with gr.Row(equal_height=False):
83
+ with gr.Column():
84
+ prompt = gr.TextArea(
85
+ label="Prompt",
86
+ show_label=False,
87
+ lines=3,
88
+ placeholder="Enter your prompt",
89
+ container=False,
90
+ )
91
 
92
  run_button = gr.Button("Run", variant="primary", scale=0)
93
 
 
146
  value=28,
147
  )
148
 
149
+ gr.Examples(
150
+ examples=examples,
151
+ fn=infer,
152
+ inputs=[prompt],
153
+ outputs=[result, download, seed],
154
+ cache_examples="lazy",
155
+ )
156
+
157
+ gr.on(
158
+ triggers=[run_button.click],
159
+ fn=lambda: gr.update(visible=False),
160
+ outputs=download,
161
+ api_name=False,
162
+ )
163
  gr.on(
164
  triggers=[run_button.click, prompt.submit],
165
  fn=infer,
 
175
  outputs=[result, download, seed],
176
  )
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  if __name__ == "__main__":
 
179
  os.makedirs("images", exist_ok=True)
180
  demo.launch()