sanbasan383 commited on
Commit
e63ab93
·
1 Parent(s): 8aa08bb

Gradio のバージョンを 3.48.0 に

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +2 -2
  3. colab-application.py +0 -69
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: gray
5
  colorTo: blue
6
  sdk: gradio
7
  python_version: 3.10.13
8
- sdk_version: 4.8.0
9
  app_file: app.py
10
  pinned: false
11
  ---
 
5
  colorTo: blue
6
  sdk: gradio
7
  python_version: 3.10.13
8
+ sdk_version: 3.48.0
9
  app_file: app.py
10
  pinned: false
11
  ---
app.py CHANGED
@@ -24,7 +24,7 @@ else:
24
  if __name__ == "__main__":
25
  interface = Interface(
26
  fn=lambda modelName, image, threshold: infer(
27
- input=np.array(PILImage.open(image)),
28
  suffix=".png",
29
  threshold=float(threshold),
30
  configPath=Path(CONFIGS_PATH + modelName + ".yaml"),
@@ -39,7 +39,7 @@ if __name__ == "__main__":
39
  label="Model",
40
  ),
41
  File(
42
- type="filepath",
43
  label="Image",
44
  file_count="single",
45
  ),
 
24
  if __name__ == "__main__":
25
  interface = Interface(
26
  fn=lambda modelName, image, threshold: infer(
27
+ input=np.array(PILImage.open(image.name)),
28
  suffix=".png",
29
  threshold=float(threshold),
30
  configPath=Path(CONFIGS_PATH + modelName + ".yaml"),
 
39
  label="Model",
40
  ),
41
  File(
42
+ type="file",
43
  label="Image",
44
  file_count="single",
45
  ),
colab-application.py DELETED
@@ -1,69 +0,0 @@
1
- import argparse
2
- from pathlib import Path
3
- from gradio import Interface
4
- from gradio.components import Dropdown, Image, File, Textbox
5
- import numpy as np
6
- from PIL import Image as PILImage
7
-
8
- from lightning_inference import infer
9
- from pyngrok import ngrok
10
- ngrok.set_auth_token("2a1nQ7HUyDDykXm4lpq3J8Mne4j_6TaqHtHyEvnEkNV9jg4ad")
11
-
12
- # コマンドライン引数の解析
13
- parser = argparse.ArgumentParser()
14
- parser.add_argument("--colab", action="store_true")
15
- args = parser.parse_args()
16
-
17
- # This environment variable is set in the Dockerfile
18
- if args.colab:
19
- CONFIGS_PATH = "/content/drive/MyDrive/anomaly-detection/huggingface/configs/"
20
- MODELS_PATH = "/content/drive/MyDrive/anomaly-detection/huggingface/models/"
21
- else:
22
- # Configured for Hugging Face environment
23
- # See: https://huggingface.co/spaces/blanchon/MVTec_Padim_Anomalib_Test/blob/main/app.py
24
- CONFIGS_PATH = "/home/user/app/configs/"
25
- MODELS_PATH = "/home/user/app/models/"
26
-
27
- if __name__ == "__main__":
28
- interface = Interface(
29
- fn=lambda modelName, image: infer(
30
- input=np.array(PILImage.open(image)),
31
- suffix=".png",
32
- configPath=Path(CONFIGS_PATH + modelName + ".yaml"),
33
- weightsPath=Path(MODELS_PATH + modelName + ".ckpt"),
34
- ),
35
- inputs=[
36
- Dropdown(
37
- choices=[
38
- "fukazara",
39
- "asahachi_black",
40
- "fukazara_scoop_black",
41
- ],
42
- label="Model",
43
- ),
44
- File(
45
- type="filepath",
46
- label="Image",
47
- file_count="single",
48
- ),
49
- ],
50
- outputs=[
51
- Image(
52
- type="numpy",
53
- label="Result",
54
- ),
55
- Image(
56
- type="numpy",
57
- label="Input",
58
- ),
59
- Textbox(
60
- value="str",
61
- type="text",
62
- label="text_result"
63
- ),
64
- ],
65
- title="Anomaly Detection with Anomalib",
66
- )
67
-
68
- url = interface.launch()
69
- print("Interface URL:", url)