Spaces:
Running
Running
MonkeyJuice
commited on
Commit
•
da72583
1
Parent(s):
8ff99b5
Update gradio
Browse files- README.md +1 -1
- app.py +5 -4
- script.js → head.html +43 -4
- style.css +0 -36
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: 👀
|
|
4 |
colorFrom: gray
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
4 |
colorFrom: gray
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.9.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
CHANGED
@@ -24,7 +24,7 @@ def predict_batch(zip_file, progress=gr.Progress()):
|
|
24 |
with zipfile.ZipFile(zip_file) as zf:
|
25 |
for file in progress.tqdm(zf.namelist()):
|
26 |
print(file)
|
27 |
-
if file.endswith(".png") or file.endswith(".jpg") or file.endswith(".jpeg"):
|
28 |
image_file = zf.open(file)
|
29 |
image = PIL.Image.open(image_file)
|
30 |
image = image.convert("RGBA")
|
@@ -34,7 +34,7 @@ def predict_batch(zip_file, progress=gr.Progress()):
|
|
34 |
result = result + str(file) + '\n' + str(tag) + '\n\n'
|
35 |
return result
|
36 |
|
37 |
-
with gr.Blocks(
|
38 |
with gr.Tab(label='Single'):
|
39 |
with gr.Row():
|
40 |
with gr.Column(scale=1):
|
@@ -42,11 +42,12 @@ with gr.Blocks(css="style.css", js="script.js") as demo:
|
|
42 |
type='pil',
|
43 |
elem_classes='m5dd_image',
|
44 |
image_mode="RGBA",
|
|
|
45 |
sources=["upload", "clipboard"])
|
46 |
run_button = gr.Button('Run')
|
47 |
-
result_text = gr.HTML(value="")
|
48 |
with gr.Column(scale=2):
|
49 |
-
result_html = gr.HTML(value="")
|
50 |
with gr.Tab(label='Batch'):
|
51 |
with gr.Row():
|
52 |
with gr.Column(scale=1):
|
|
|
24 |
with zipfile.ZipFile(zip_file) as zf:
|
25 |
for file in progress.tqdm(zf.namelist()):
|
26 |
print(file)
|
27 |
+
if file.endswith(".png") or file.endswith(".jpg") or file.endswith(".jpeg") or file.endswith(".webp"):
|
28 |
image_file = zf.open(file)
|
29 |
image = PIL.Image.open(image_file)
|
30 |
image = image.convert("RGBA")
|
|
|
34 |
result = result + str(file) + '\n' + str(tag) + '\n\n'
|
35 |
return result
|
36 |
|
37 |
+
with gr.Blocks(head_paths="head.html") as demo:
|
38 |
with gr.Tab(label='Single'):
|
39 |
with gr.Row():
|
40 |
with gr.Column(scale=1):
|
|
|
42 |
type='pil',
|
43 |
elem_classes='m5dd_image',
|
44 |
image_mode="RGBA",
|
45 |
+
show_fullscreen_button=False,
|
46 |
sources=["upload", "clipboard"])
|
47 |
run_button = gr.Button('Run')
|
48 |
+
result_text = gr.HTML(value="", elem_classes='m5dd_html', padding=False)
|
49 |
with gr.Column(scale=2):
|
50 |
+
result_html = gr.HTML(value="", elem_classes='m5dd_html', padding=False)
|
51 |
with gr.Tab(label='Batch'):
|
52 |
with gr.Row():
|
53 |
with gr.Column(scale=1):
|
script.js → head.html
RENAMED
@@ -1,5 +1,45 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
document.addEventListener('click', function (event) {
|
4 |
let tagItem = event.target.closest('.m5dd_list')
|
5 |
let resultArea = event.target.closest('#m5dd_result')
|
@@ -44,5 +84,4 @@ async () => {
|
|
44 |
return
|
45 |
}
|
46 |
})
|
47 |
-
|
48 |
-
}
|
|
|
1 |
+
<style>
|
2 |
+
.m5dd_list {
|
3 |
+
display: flex;
|
4 |
+
cursor: pointer;
|
5 |
+
font-size: 1.2em;
|
6 |
+
padding: .5em;
|
7 |
+
user-select: none;
|
8 |
+
}
|
9 |
+
.m5dd_list>span.label {
|
10 |
+
flex: 1;
|
11 |
+
padding: 0 .5em;
|
12 |
+
}
|
13 |
+
|
14 |
+
.m5dd_list>span.prob {
|
15 |
+
color: #aaa;
|
16 |
+
padding: 0 .5em;
|
17 |
+
}
|
18 |
+
|
19 |
+
.m5dd_list:nth-child(even) { background: #ECEDF0; }
|
20 |
+
.dark .m5dd_list:nth-child(even) { background: #1F2937; }
|
21 |
+
|
22 |
+
.m5dd_list:not(.use)>span.label {
|
23 |
+
text-decoration: line-through;
|
24 |
+
color: #ccc;
|
25 |
+
}
|
26 |
+
|
27 |
+
.m5dd_image .upload-container .image-frame {
|
28 |
+
height: 20em;
|
29 |
+
}
|
30 |
+
|
31 |
+
.m5dd_image .upload-container .image-frame {
|
32 |
+
height: 20em;
|
33 |
+
}
|
34 |
+
.m5dd_image2 .image-container {
|
35 |
+
height: 20em;
|
36 |
+
}
|
37 |
+
.m5dd_html{
|
38 |
+
min-height: 6em;
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
|
42 |
+
<script>
|
43 |
document.addEventListener('click', function (event) {
|
44 |
let tagItem = event.target.closest('.m5dd_list')
|
45 |
let resultArea = event.target.closest('#m5dd_result')
|
|
|
84 |
return
|
85 |
}
|
86 |
})
|
87 |
+
</script>
|
|
style.css
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
.m5dd_list {
|
2 |
-
display: flex;
|
3 |
-
cursor: pointer;
|
4 |
-
font-size: 1.2em;
|
5 |
-
padding: .5em;
|
6 |
-
user-select: none;
|
7 |
-
}
|
8 |
-
|
9 |
-
.m5dd_list>span.label {
|
10 |
-
flex: 1;
|
11 |
-
padding: 0 .5em;
|
12 |
-
}
|
13 |
-
|
14 |
-
.m5dd_list>span.prob {
|
15 |
-
color: #aaa;
|
16 |
-
padding: 0 .5em;
|
17 |
-
}
|
18 |
-
|
19 |
-
.m5dd_list:nth-child(even) { background: #ECEDF0; }
|
20 |
-
.dark .m5dd_list:nth-child(even) { background: #1F2937; }
|
21 |
-
|
22 |
-
.m5dd_list:not(.use)>span.label {
|
23 |
-
text-decoration: line-through;
|
24 |
-
color: #ccc;
|
25 |
-
}
|
26 |
-
|
27 |
-
.m5dd_image .upload-container .image-frame {
|
28 |
-
height: 20em;
|
29 |
-
}
|
30 |
-
|
31 |
-
.m5dd_image .upload-container .image-frame {
|
32 |
-
height: 20em;
|
33 |
-
}
|
34 |
-
.m5dd_image2 .image-container {
|
35 |
-
height: 20em;
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|