Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,17 @@ def list_files(model_name):
|
|
| 9 |
files = api.list_repo_files(repo_id=model_name,repo_type="model")
|
| 10 |
return gr.update(choices=[m for m in files],interactive=True)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def load_models(model_in):
|
| 13 |
loaded_model=[]
|
| 14 |
model_details=[]
|
|
@@ -30,16 +41,20 @@ def load_models(model_in):
|
|
| 30 |
except Exception as ee:
|
| 31 |
model_details.append({"MODEL":model.id,"ERROR":ee})
|
| 32 |
return loaded_model, model_details
|
|
|
|
|
|
|
| 33 |
with gr.Blocks() as app:
|
| 34 |
with gr.Row():
|
| 35 |
model_name=gr.Textbox(label="Model", value=models[0], placeholder=models[0])
|
| 36 |
load_btn=gr.Button("Load")
|
| 37 |
with gr.Row():
|
| 38 |
file_name=gr.Dropdown(label="Files", choices=[])
|
|
|
|
| 39 |
with gr.Row():
|
| 40 |
models_out=gr.JSON(label="Gradio Details")
|
| 41 |
details=gr.JSON(label="Hub Details")
|
| 42 |
app.load(list_files,model_name,[file_name])
|
|
|
|
| 43 |
#app.load(load_models,model_name,[models_out,details])
|
| 44 |
load_btn.click(load_models,model_name,[models_out,details])
|
| 45 |
app.launch()
|
|
|
|
| 9 |
files = api.list_repo_files(repo_id=model_name,repo_type="model")
|
| 10 |
return gr.update(choices=[m for m in files],interactive=True)
|
| 11 |
|
| 12 |
+
def load_bin(model_name,file_name):
|
| 13 |
+
r = requests.get(f'https://huggingface.co/models/{model_name}/raw/main/{file_name}')
|
| 14 |
+
return r.content
|
| 15 |
+
#with open()
|
| 16 |
+
#file = open(f'{name}/{f_name}','wb')
|
| 17 |
+
#file = open(f'{name}/{f_name}','wb')
|
| 18 |
+
#file.write(r.content)
|
| 19 |
+
#file.close()
|
| 20 |
+
#file_list.append(f'{name}/{f_name}')
|
| 21 |
+
|
| 22 |
+
|
| 23 |
def load_models(model_in):
|
| 24 |
loaded_model=[]
|
| 25 |
model_details=[]
|
|
|
|
| 41 |
except Exception as ee:
|
| 42 |
model_details.append({"MODEL":model.id,"ERROR":ee})
|
| 43 |
return loaded_model, model_details
|
| 44 |
+
|
| 45 |
+
|
| 46 |
with gr.Blocks() as app:
|
| 47 |
with gr.Row():
|
| 48 |
model_name=gr.Textbox(label="Model", value=models[0], placeholder=models[0])
|
| 49 |
load_btn=gr.Button("Load")
|
| 50 |
with gr.Row():
|
| 51 |
file_name=gr.Dropdown(label="Files", choices=[])
|
| 52 |
+
bin_btn=gr.Button("Binary")
|
| 53 |
with gr.Row():
|
| 54 |
models_out=gr.JSON(label="Gradio Details")
|
| 55 |
details=gr.JSON(label="Hub Details")
|
| 56 |
app.load(list_files,model_name,[file_name])
|
| 57 |
+
bin_btn.click(load_bin,[model_name,file_name],details)
|
| 58 |
#app.load(load_models,model_name,[models_out,details])
|
| 59 |
load_btn.click(load_models,model_name,[models_out,details])
|
| 60 |
app.launch()
|