Spaces:
Running
Running
admin
commited on
Commit
·
eec14f7
1
Parent(s):
cbe55f0
sync ms
Browse files- app.py +20 -6
- requirements.txt +2 -2
app.py
CHANGED
@@ -9,6 +9,20 @@ from bs4 import BeautifulSoup
|
|
9 |
|
10 |
V_TO_SPLIT = {"IMAGENET1K_V1": "train", "IMAGENET1K_V2": "test"}
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def parse_url(url: str):
|
14 |
response = requests.get(url)
|
@@ -120,7 +134,7 @@ def sync(subset: str):
|
|
120 |
os.remove(cache_json)
|
121 |
|
122 |
if os.path.exists(cache_json):
|
123 |
-
raise
|
124 |
|
125 |
except Exception as e:
|
126 |
status = f"{e}"
|
@@ -133,18 +147,18 @@ if __name__ == "__main__":
|
|
133 |
with gr.Row():
|
134 |
with gr.Column():
|
135 |
subset_opt = gr.Dropdown(
|
136 |
-
label="ImageNet version",
|
137 |
choices=["IMAGENET1K_V1", "IMAGENET1K_V2"],
|
138 |
value="IMAGENET1K_V1",
|
139 |
)
|
140 |
-
sync_btn = gr.Button("Clean cache")
|
141 |
|
142 |
with gr.Column():
|
143 |
-
status_bar = gr.Textbox(label="Status", show_copy_button=True)
|
144 |
-
dld_file = gr.File(label="Download JSON lines")
|
145 |
|
146 |
with gr.Row():
|
147 |
-
data_frame = gr.Dataframe(label="Preview")
|
148 |
|
149 |
subset_opt.change(
|
150 |
infer,
|
|
|
9 |
|
10 |
V_TO_SPLIT = {"IMAGENET1K_V1": "train", "IMAGENET1K_V2": "test"}
|
11 |
|
12 |
+
EN_US = os.getenv("LANG") != "zh_CN.UTF-8"
|
13 |
+
|
14 |
+
EN2ZH = {
|
15 |
+
"ImageNet version": "ImageNet 版本",
|
16 |
+
"Clean cache": "清理缓存",
|
17 |
+
"Status": "状态栏",
|
18 |
+
"Download JSON lines": "下载 jsonl",
|
19 |
+
"Preview": "预览",
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
def _L(en_txt: str):
|
24 |
+
return en_txt if EN_US else f"{en_txt} ({EN2ZH[en_txt]})"
|
25 |
+
|
26 |
|
27 |
def parse_url(url: str):
|
28 |
response = requests.get(url)
|
|
|
134 |
os.remove(cache_json)
|
135 |
|
136 |
if os.path.exists(cache_json):
|
137 |
+
raise FileExistsError(f"Failed to clean {cache_json}")
|
138 |
|
139 |
except Exception as e:
|
140 |
status = f"{e}"
|
|
|
147 |
with gr.Row():
|
148 |
with gr.Column():
|
149 |
subset_opt = gr.Dropdown(
|
150 |
+
label=_L("ImageNet version"),
|
151 |
choices=["IMAGENET1K_V1", "IMAGENET1K_V2"],
|
152 |
value="IMAGENET1K_V1",
|
153 |
)
|
154 |
+
sync_btn = gr.Button(_L("Clean cache"))
|
155 |
|
156 |
with gr.Column():
|
157 |
+
status_bar = gr.Textbox(label=_L("Status"), show_copy_button=True)
|
158 |
+
dld_file = gr.File(label=_L("Download JSON lines"))
|
159 |
|
160 |
with gr.Row():
|
161 |
+
data_frame = gr.Dataframe(label=_L("Preview"))
|
162 |
|
163 |
subset_opt.change(
|
164 |
infer,
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
|
2 |
-
|
|
|
1 |
+
pandas
|
2 |
+
beautifulsoup4
|