Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,12 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import tempfile
|
| 3 |
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def create():
|
| 6 |
color='blue'
|
|
@@ -16,14 +22,23 @@ def create():
|
|
| 16 |
|
| 17 |
# Save the image to disk
|
| 18 |
image.save(temp_file, format='PNG')
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# usage:
|
| 23 |
|
| 24 |
with gr.Blocks(delete_cache=(2,4)) as demo:
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
btn = gr.Button("GO!")
|
| 27 |
-
btn.click(create,inputs=[],outputs=out)
|
| 28 |
|
| 29 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import tempfile
|
| 3 |
from PIL import Image
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
# Get the path to the temporary directory
|
| 7 |
+
temp_dir = tempfile.gettempdir()
|
| 8 |
+
print(f"Temporary directory : {temp_dir}")
|
| 9 |
+
|
| 10 |
|
| 11 |
def create():
|
| 12 |
color='blue'
|
|
|
|
| 22 |
|
| 23 |
# Save the image to disk
|
| 24 |
image.save(temp_file, format='PNG')
|
| 25 |
+
|
| 26 |
+
# List all files in the temporary directory
|
| 27 |
+
print('_________________')
|
| 28 |
+
temp_files = os.listdir(temp_dir)
|
| 29 |
+
print(f"Temporary files and directories in '{temp_dir}':")
|
| 30 |
+
for file in temp_files:
|
| 31 |
+
print(file)
|
| 32 |
+
print('_________________')
|
| 33 |
+
return temp_file.name, temp_files
|
| 34 |
|
| 35 |
# usage:
|
| 36 |
|
| 37 |
with gr.Blocks(delete_cache=(2,4)) as demo:
|
| 38 |
+
with gr.Row():
|
| 39 |
+
tb = gr.Textbox()
|
| 40 |
+
out = gr.Image(type='filepath')
|
| 41 |
btn = gr.Button("GO!")
|
| 42 |
+
btn.click(create,inputs=[],outputs=[out, tb])
|
| 43 |
|
| 44 |
demo.launch()
|