ysharma HF Staff commited on
Commit
89d1d2c
·
verified ·
1 Parent(s): f2b7407

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import tempfile
3
  from PIL import Image
 
4
  import os
5
 
6
  # Assuming 'my_directory' is a directory in the current working directory
@@ -10,9 +11,9 @@ import os
10
  #/home/user/app/temp_dir
11
 
12
  # Access the environment variable
13
- os.environ['GRADIO_TEMP_DIR'] = 'temp_dir'
14
- gradio_temp_dir = os.environ['GRADIO_TEMP_DIR']
15
- print(f'GRADIO_TEMP_DIR is = {gradio_temp_dir}')
16
 
17
  current_directory = os.getcwd()
18
  print(f'current_directory is = {current_directory}')
@@ -49,7 +50,7 @@ def create():
49
 
50
 
51
  # Specify the directory you want to search in, e.g., the current directory
52
- directory = 'temp_dir'
53
  # List all entries in the directory
54
  entries = os.listdir(directory)
55
  print(f"listdir of temp_dir directory = {entries}")
@@ -58,7 +59,7 @@ def create():
58
  return temp_file.name, temp_directory_file_list
59
 
60
 
61
- with gr.Blocks(delete_cache=(2,2),
62
  theme=gr.themes.Base(radius_size="none")) as demo:
63
  with gr.Row():
64
  inp = gr.Textbox(placeholder="What is your name?")
@@ -66,4 +67,6 @@ with gr.Blocks(delete_cache=(2,2),
66
  btn = gr.Button("GO!")
67
  btn.click(create,inputs=[],outputs=[out, inp])
68
 
 
 
69
  demo.launch(debug=False)
 
1
  import gradio as gr
2
  import tempfile
3
  from PIL import Image
4
+ import uuid
5
  import os
6
 
7
  # Assuming 'my_directory' is a directory in the current working directory
 
11
  #/home/user/app/temp_dir
12
 
13
  # Access the environment variable
14
+ #os.environ['GRADIO_TEMP_DIR'] = 'temp_dir'
15
+ #gradio_temp_dir = os.environ['GRADIO_TEMP_DIR']
16
+ #print(f'GRADIO_TEMP_DIR is = {gradio_temp_dir}')
17
 
18
  current_directory = os.getcwd()
19
  print(f'current_directory is = {current_directory}')
 
50
 
51
 
52
  # Specify the directory you want to search in, e.g., the current directory
53
+ directory = 'testing'
54
  # List all entries in the directory
55
  entries = os.listdir(directory)
56
  print(f"listdir of temp_dir directory = {entries}")
 
59
  return temp_file.name, temp_directory_file_list
60
 
61
 
62
+ with gr.Blocks(delete_cache=(5,10),
63
  theme=gr.themes.Base(radius_size="none")) as demo:
64
  with gr.Row():
65
  inp = gr.Textbox(placeholder="What is your name?")
 
67
  btn = gr.Button("GO!")
68
  btn.click(create,inputs=[],outputs=[out, inp])
69
 
70
+ filepath11 = demo.move_resource_to_block_cache('/content/testing/mp333.png')
71
+ print(f'filepath11 ^^^^^^= {filepath11}')
72
  demo.launch(debug=False)