Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import warnings
|
| 2 |
warnings.filterwarnings("ignore")
|
| 3 |
-
import os
|
| 4 |
import transformers
|
| 5 |
transformers.logging.set_verbosity_error()
|
| 6 |
|
|
@@ -39,7 +41,9 @@ for i, (_, row) in enumerate(df_samples.iterrows()):
|
|
| 39 |
"animal_dataset/animals/animals",
|
| 40 |
"./animals/animals"
|
| 41 |
)
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# 3. INITIALIZE MODEL ARCHITECTURE
|
| 45 |
class VQAModel(nn.Module):
|
|
@@ -121,10 +125,11 @@ demo = gr.Interface(
|
|
| 121 |
],
|
| 122 |
outputs=gr.Textbox(label="Answer"),
|
| 123 |
examples=examples_list,
|
| 124 |
-
cache_examples=False,
|
| 125 |
title="Vi-VQA Animal",
|
| 126 |
theme=gr.themes.Default(primary_hue="orange")
|
| 127 |
)
|
| 128 |
|
|
|
|
| 129 |
if __name__ == "__main__":
|
| 130 |
-
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.environ["GRADIO_ALLOWED_PATHS"] = os.path.abspath("./")
|
| 3 |
+
|
| 4 |
import warnings
|
| 5 |
warnings.filterwarnings("ignore")
|
|
|
|
| 6 |
import transformers
|
| 7 |
transformers.logging.set_verbosity_error()
|
| 8 |
|
|
|
|
| 41 |
"animal_dataset/animals/animals",
|
| 42 |
"./animals/animals"
|
| 43 |
)
|
| 44 |
+
# Double check if file exists on server before adding to examples
|
| 45 |
+
if os.path.exists(img_path):
|
| 46 |
+
examples_list.append([img_path, custom_questions[i]])
|
| 47 |
|
| 48 |
# 3. INITIALIZE MODEL ARCHITECTURE
|
| 49 |
class VQAModel(nn.Module):
|
|
|
|
| 125 |
],
|
| 126 |
outputs=gr.Textbox(label="Answer"),
|
| 127 |
examples=examples_list,
|
| 128 |
+
cache_examples=False,
|
| 129 |
title="Vi-VQA Animal",
|
| 130 |
theme=gr.themes.Default(primary_hue="orange")
|
| 131 |
)
|
| 132 |
|
| 133 |
+
# Launch with explicit paths allowed
|
| 134 |
if __name__ == "__main__":
|
| 135 |
+
demo.launch(allowed_paths=[os.path.abspath("./")])
|