Spaces:
Runtime error
Runtime error
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
import time
|
4 |
+
|
5 |
+
|
6 |
+
def predict(x):
|
7 |
+
return np.fliplr(x)
|
8 |
+
|
9 |
+
|
10 |
+
def compress():
|
11 |
+
time.sleep(1)
|
12 |
+
return 'The model has been compressed successfully.'
|
13 |
+
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
with gr.Column():
|
17 |
+
gr.Radio(["Image classification", "Object detection", "Semantic segmentation"], label="Tasks"),
|
18 |
+
gr.Radio(["ResNet", "VGG", "MobileNet"], label="Models"),
|
19 |
+
gr.Radio(["Weight quantization","Knowledge distillation","Network pruning", "Neural Architecture Search"],
|
20 |
+
label="Compression methods"),
|
21 |
+
gr.Radio(["Jetson Nano"], label="Deployments")
|
22 |
+
compress_btn = gr.Button("compress")
|
23 |
+
output_compress = gr.Textbox(lines=1, label="Model Compression Results", visible=False)
|
24 |
+
|
25 |
+
with gr.Row():
|
26 |
+
Original_config = gr.Dataframe(headers=["#Params.(M)", "FLOPs(G)"], datatype=[
|
27 |
+
"str", "str"], row_count=1, value=[['63.8M','250G']], label="Original model config", visible=False)
|
28 |
+
Compressed_config = gr.Dataframe(headers=["#Params.(M)", "FLOPs(G)"], datatype=[
|
29 |
+
"str", "str"], row_count=1, value=[['34.6M','126G']],label="Compressed model config", visible=False)
|
30 |
+
with gr.Row():
|
31 |
+
input_predict = gr.Image(label="input")
|
32 |
+
output_predict = gr.Image(label="output")
|
33 |
+
predict_btn = gr.Button("predict")
|
34 |
+
state = gr.State()
|
35 |
+
compress_btn.click(fn=compress, inputs=None,
|
36 |
+
outputs=output_compress, api_name="compress")
|
37 |
+
compress_btn.click(lambda : (gr.Textbox.update(visible=True), "visible"), None, [output_compress, state])
|
38 |
+
output_compress.change(lambda: (Original_config.update(visible=True), "visible"), None, [Original_config, state])
|
39 |
+
output_compress.change(lambda: (Compressed_config.update(visible=True), "visible"), None, [Compressed_config, state])
|
40 |
+
predict_btn.click(fn=predict, inputs=input_predict,
|
41 |
+
outputs=output_predict, api_name="predict")
|
42 |
+
|
43 |
+
demo.launch(share=True)
|