siriuszeina commited on
Commit
8ad663e
·
verified ·
1 Parent(s): 5146ec7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -25
app.py CHANGED
@@ -18,14 +18,6 @@ import tensorflow as tf
18
  DESCRIPTION = "# [KichangKim/DeepDanbooru](https://github.com/KichangKim/DeepDanbooru)"
19
 
20
 
21
- def load_sample_image_paths() -> list[pathlib.Path]:
22
- image_dir = pathlib.Path("images")
23
- if not image_dir.exists():
24
- path = huggingface_hub.hf_hub_download("public-data/sample-images-TADNE", "images.tar.gz", repo_type="dataset")
25
- with tarfile.open(path) as f:
26
- f.extractall()
27
- return sorted(image_dir.glob("*"))
28
-
29
 
30
  def load_model() -> tf.keras.Model:
31
  path = huggingface_hub.hf_hub_download("public-data/DeepDanbooru", "model-resnet_custom_v3.h5")
@@ -70,8 +62,6 @@ def predict(url: str, score_threshold: float) -> tuple[dict[str, float], dict[st
70
  return result_threshold, result_all, result_text
71
 
72
 
73
- image_paths = load_sample_image_paths()
74
- examples = [[path.as_posix(), 0.5] for path in image_paths]
75
 
76
  with gr.Blocks(css="style.css") as demo:
77
  gr.Markdown(DESCRIPTION)
@@ -83,21 +73,7 @@ with gr.Blocks(css="style.css") as demo:
83
 
84
  score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
85
  run_button = gr.Button("Run")
86
- with gr.Column():
87
- with gr.Tabs():
88
- with gr.Tab(label="Output"):
89
- result = gr.Label(label="Output", show_label=False)
90
- with gr.Tab(label="JSON"):
91
- result_json = gr.JSON(label="JSON output", show_label=False)
92
- with gr.Tab(label="Text"):
93
- result_text = gr.Text(label="Text output", show_label=False, lines=5)
94
- gr.Examples(
95
- examples=examples,
96
- inputs=[url, score_threshold],
97
- outputs=[result, result_json, result_text],
98
- fn=predict,
99
- cache_examples=os.getenv("CACHE_EXAMPLES") == "1",
100
- )
101
 
102
  run_button.click(
103
  fn=predict,
 
18
  DESCRIPTION = "# [KichangKim/DeepDanbooru](https://github.com/KichangKim/DeepDanbooru)"
19
 
20
 
 
 
 
 
 
 
 
 
21
 
22
  def load_model() -> tf.keras.Model:
23
  path = huggingface_hub.hf_hub_download("public-data/DeepDanbooru", "model-resnet_custom_v3.h5")
 
62
  return result_threshold, result_all, result_text
63
 
64
 
 
 
65
 
66
  with gr.Blocks(css="style.css") as demo:
67
  gr.Markdown(DESCRIPTION)
 
73
 
74
  score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
75
  run_button = gr.Button("Run")
76
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  run_button.click(
79
  fn=predict,