Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,29 +3,28 @@ import gradio as gr
|
|
| 3 |
import tempfile
|
| 4 |
import os
|
| 5 |
import sr100_model_compiler
|
| 6 |
-
from huggingface_hub import HfApi
|
| 7 |
-
from huggingface_hub import whoami
|
| 8 |
-
|
| 9 |
# Get top-level authorizations
|
| 10 |
-
oauth_info = {'username' : None, 'token' : None}
|
| 11 |
-
api = HfApi()
|
| 12 |
-
|
| 13 |
-
def get_oauth_info(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> str:
|
| 14 |
-
global oauth_info
|
| 15 |
-
global api
|
| 16 |
-
|
| 17 |
-
print(f'profile = {profile}')
|
| 18 |
-
if profile is None:
|
| 19 |
-
oauth_info['username'] = None
|
| 20 |
-
oauth_info['token'] = None
|
| 21 |
-
return "Please login to the Huggingface with login button"
|
| 22 |
-
else:
|
| 23 |
-
#print(f'Testing {profile} for username')
|
| 24 |
-
oauth_info['username'] = profile.username
|
| 25 |
-
oauth_info['token'] = oauth_token.token
|
| 26 |
-
org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
|
| 27 |
-
|
| 28 |
-
return print(f'{profile.username}: {org_names}')
|
| 29 |
|
| 30 |
|
| 31 |
def compile_model(model_name, vmem_value, lpmem_value):
|
|
@@ -61,7 +60,7 @@ def compile_model(model_name, vmem_value, lpmem_value):
|
|
| 61 |
output_text = 'FAILURE, model does not fit on SR100'
|
| 62 |
|
| 63 |
weights_size = results['weights_size'] / 1000.0
|
| 64 |
-
arena_size = results['arena_cache_size'] /
|
| 65 |
clock = results['core_clock'] / 1.0e6
|
| 66 |
|
| 67 |
output_text += f'<br>clock = {clock:0.1f} MHz'
|
|
@@ -70,14 +69,15 @@ def compile_model(model_name, vmem_value, lpmem_value):
|
|
| 70 |
output_text += f'<br>model loc = {results["model_loc"]}'
|
| 71 |
output_text += f'<br>System config = {results["system_config"]}'
|
| 72 |
|
| 73 |
-
|
| 74 |
vmem_size = results['vmem_size'] / 1000.0
|
| 75 |
lpmem_size = results['lpmem_size'] / 1000.0
|
|
|
|
|
|
|
| 76 |
vmem_perc = results['vmem_size'] * 100.0 / results['vmem_size_limit']
|
| 77 |
lpmem_perc = results['lpmem_size'] * 100.0 / results['lpmem_size_limit']
|
| 78 |
|
| 79 |
-
output_text += f'<br>vmem_size = {vmem_size:0.3f} kB ({vmem_perc:0.1f}%)'
|
| 80 |
-
output_text += f'<br>lpmem_size = {lpmem_size:0.3f} kB ({lpmem_perc:0.1f}%)'
|
| 81 |
|
| 82 |
|
| 83 |
return output_text
|
|
@@ -86,7 +86,7 @@ def compile_model(model_name, vmem_value, lpmem_value):
|
|
| 86 |
model_choices = glob.glob('models/*.tflite')
|
| 87 |
|
| 88 |
with gr.Blocks() as demo:
|
| 89 |
-
gr.LoginButton()
|
| 90 |
text1 = gr.Markdown("SR100 Model Compiler - Compile a tflite model to SR100")
|
| 91 |
user_text = gr.Markdown("")
|
| 92 |
|
|
|
|
| 3 |
import tempfile
|
| 4 |
import os
|
| 5 |
import sr100_model_compiler
|
| 6 |
+
#from huggingface_hub import HfApi
|
| 7 |
+
#from huggingface_hub import whoami
|
|
|
|
| 8 |
# Get top-level authorizations
|
| 9 |
+
#oauth_info = {'username' : None, 'token' : None}
|
| 10 |
+
#api = HfApi()
|
| 11 |
+
#
|
| 12 |
+
#def get_oauth_info(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> str:
|
| 13 |
+
# global oauth_info
|
| 14 |
+
# global api
|
| 15 |
+
|
| 16 |
+
# print(f'profile = {profile}')
|
| 17 |
+
# if profile is None:
|
| 18 |
+
# oauth_info['username'] = None
|
| 19 |
+
# oauth_info['token'] = None
|
| 20 |
+
# return "Please login to the Huggingface with login button"
|
| 21 |
+
# else:
|
| 22 |
+
# #print(f'Testing {profile} for username')
|
| 23 |
+
# oauth_info['username'] = profile.username
|
| 24 |
+
# oauth_info['token'] = oauth_token.token
|
| 25 |
+
# org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
|
| 26 |
+
#
|
| 27 |
+
# return print(f'{profile.username}: {org_names}')
|
| 28 |
|
| 29 |
|
| 30 |
def compile_model(model_name, vmem_value, lpmem_value):
|
|
|
|
| 60 |
output_text = 'FAILURE, model does not fit on SR100'
|
| 61 |
|
| 62 |
weights_size = results['weights_size'] / 1000.0
|
| 63 |
+
arena_size = results['arena_cache_size'] / 1000.0
|
| 64 |
clock = results['core_clock'] / 1.0e6
|
| 65 |
|
| 66 |
output_text += f'<br>clock = {clock:0.1f} MHz'
|
|
|
|
| 69 |
output_text += f'<br>model loc = {results["model_loc"]}'
|
| 70 |
output_text += f'<br>System config = {results["system_config"]}'
|
| 71 |
|
|
|
|
| 72 |
vmem_size = results['vmem_size'] / 1000.0
|
| 73 |
lpmem_size = results['lpmem_size'] / 1000.0
|
| 74 |
+
vmem_size_limit = results['vmem_size_limit'] / 1000.0
|
| 75 |
+
lpmem_size_limit = results['lpmem_size_limit'] / 1000.0
|
| 76 |
vmem_perc = results['vmem_size'] * 100.0 / results['vmem_size_limit']
|
| 77 |
lpmem_perc = results['lpmem_size'] * 100.0 / results['lpmem_size_limit']
|
| 78 |
|
| 79 |
+
output_text += f'<br>vmem_size = {vmem_size:0.3f} kB ({vmem_perc:0.1f}% of {vmem_size_limit:0.3f} kB)'
|
| 80 |
+
output_text += f'<br>lpmem_size = {lpmem_size:0.3f} kB ({lpmem_perc:0.1f}% of {lpmem_size_limit:0.3f} kB)'
|
| 81 |
|
| 82 |
|
| 83 |
return output_text
|
|
|
|
| 86 |
model_choices = glob.glob('models/*.tflite')
|
| 87 |
|
| 88 |
with gr.Blocks() as demo:
|
| 89 |
+
#gr.LoginButton()
|
| 90 |
text1 = gr.Markdown("SR100 Model Compiler - Compile a tflite model to SR100")
|
| 91 |
user_text = gr.Markdown("")
|
| 92 |
|