Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,19 +25,18 @@ def get_oauth_info(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken |
|
|
| 25 |
return print(f'{profile.username}: {org_names}')
|
| 26 |
|
| 27 |
|
| 28 |
-
def compile_model(model_name):
|
| 29 |
|
| 30 |
if oauth_info['token'] is None:
|
| 31 |
return "ERROR - please log into HuggingFace to continue"
|
| 32 |
|
| 33 |
# Run the comparison
|
| 34 |
-
model = 'hello_world.tflite'
|
| 35 |
out_dir = './tmp'
|
| 36 |
model_loc = 'sram'
|
| 37 |
|
| 38 |
# Run the model fitter
|
| 39 |
results = sr100_model_compiler.sr100_model_compiler(
|
| 40 |
-
model_file=
|
| 41 |
output_dir=f"{out_dir}",
|
| 42 |
model_loc=f"{model_loc}",
|
| 43 |
)
|
|
@@ -57,19 +56,31 @@ def compile_model(model_name):
|
|
| 57 |
# Run the training
|
| 58 |
# return model.run_training(epochs=epochs, batch=batch)
|
| 59 |
|
| 60 |
-
return f"Compiled model {success} {perf_data}"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
with gr.Blocks() as demo:
|
| 63 |
gr.LoginButton()
|
| 64 |
-
text1 = gr.Markdown("
|
| 65 |
-
|
| 66 |
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
compile_btn = gr.Button("Compile Model")
|
| 70 |
-
compile_text = gr.Markdown("
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
demo.load(get_oauth_info, inputs=None, outputs=user_text)
|
| 74 |
|
| 75 |
if __name__ == "__main__":
|
|
|
|
| 25 |
return print(f'{profile.username}: {org_names}')
|
| 26 |
|
| 27 |
|
| 28 |
+
def compile_model(model_name, sram_size, tensor_size):
|
| 29 |
|
| 30 |
if oauth_info['token'] is None:
|
| 31 |
return "ERROR - please log into HuggingFace to continue"
|
| 32 |
|
| 33 |
# Run the comparison
|
|
|
|
| 34 |
out_dir = './tmp'
|
| 35 |
model_loc = 'sram'
|
| 36 |
|
| 37 |
# Run the model fitter
|
| 38 |
results = sr100_model_compiler.sr100_model_compiler(
|
| 39 |
+
model_file=model_name,
|
| 40 |
output_dir=f"{out_dir}",
|
| 41 |
model_loc=f"{model_loc}",
|
| 42 |
)
|
|
|
|
| 56 |
# Run the training
|
| 57 |
# return model.run_training(epochs=epochs, batch=batch)
|
| 58 |
|
| 59 |
+
return f"Compiled model: {sram_size} {tensor_size} {success} {perf_data}"
|
| 60 |
+
|
| 61 |
+
#def process_data(slider_value):
|
| 62 |
+
# return slider_value * 2
|
| 63 |
+
|
| 64 |
|
| 65 |
with gr.Blocks() as demo:
|
| 66 |
gr.LoginButton()
|
| 67 |
+
text1 = gr.Markdown("SR100 Model Compiler - Compile a tflite model to SR100")
|
| 68 |
+
|
| 69 |
|
| 70 |
+
# Deploy the two slides
|
| 71 |
+
sram_slider = gr.Slider(minimum=0, maximum=3, step=0.1, label="Set total SRAM size available in MB", value=3)
|
| 72 |
+
tensor_slider = gr.Slider(minimum=0, maximum=3, step=0.1, label="Set the SRAM size for tensor calculations in MB", value=1.5)
|
| 73 |
+
#output_text = gr.Textbox(label="Output")
|
| 74 |
+
|
| 75 |
+
model_text = gr.Textbox(label='TFlite model', value='hello_world.tflite')
|
| 76 |
|
| 77 |
compile_btn = gr.Button("Compile Model")
|
| 78 |
+
compile_text = gr.Markdown("Waiting for model")
|
| 79 |
+
user_text = gr.Markdown("")
|
| 80 |
+
|
| 81 |
+
# Compute options
|
| 82 |
+
compile_btn.click(compile_model, inputs=[model_text, sram_slider, tensor_slider], outputs=[compile_text])
|
| 83 |
+
#my_slider.change(fn=process_data, inputs=my_slider, outputs=output_text)
|
| 84 |
demo.load(get_oauth_info, inputs=None, outputs=user_text)
|
| 85 |
|
| 86 |
if __name__ == "__main__":
|