jadechoghari commited on
Commit
1b3547a
1 Parent(s): 98d0bf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -25,6 +25,13 @@ model.setup()
25
 
26
  CACHE_DIR = "gradio_cached_examples"
27
 
 
 
 
 
 
 
 
28
  #for local cache
29
  def load_cached_example_outputs(example_index: int) -> Tuple[str, str]:
30
  cached_dir = os.path.join(CACHE_DIR, str(example_index)) # Use the example index to find the directory
@@ -126,16 +133,11 @@ with gr.Blocks(css=css) as demo:
126
  return load_cached_example_outputs(example_index)
127
 
128
  gr.Examples(
129
- examples=[
130
- ["examples/1.png", 3, "A scenic mountain view", 500], # Example 1
131
- ["examples/2.png", 2, "A forest with birds", 500], # Example 2
132
- ["examples/3.png", 1, "A crowded city", 500] # Example 3
133
- ],
134
  inputs=[image, num_audios, prompt, steps],
135
  outputs=[processed_image, generated_audio],
136
  cache_examples=True, # Cache examples to avoid running the model
137
- fn=update_examples, # Call function that loads example based on index
138
- inputs=[index_selector] # Use the dropdown to select the example index
139
  )
140
 
141
  gr.on(
 
25
 
26
  CACHE_DIR = "gradio_cached_examples"
27
 
28
+
29
+ example_mapping = {
30
+ 1: os.path.join(CACHE_DIR, "1"),
31
+ 2: os.path.join(CACHE_DIR, "2"),
32
+ 3: os.path.join(CACHE_DIR, "3")
33
+ }
34
+
35
  #for local cache
36
  def load_cached_example_outputs(example_index: int) -> Tuple[str, str]:
37
  cached_dir = os.path.join(CACHE_DIR, str(example_index)) # Use the example index to find the directory
 
133
  return load_cached_example_outputs(example_index)
134
 
135
  gr.Examples(
136
+ examples=examples, # Example inputs
 
 
 
 
137
  inputs=[image, num_audios, prompt, steps],
138
  outputs=[processed_image, generated_audio],
139
  cache_examples=True, # Cache examples to avoid running the model
140
+ fn=lambda *args: on_example_click(int(args[0].split('/')[-1][0])) # Extract example index from image path
 
141
  )
142
 
143
  gr.on(