Spaces:
Sleeping
Sleeping
Update app.py (#5)
Browse files- Update app.py (d25d1b26551abb97ad5c158e3ed5a981d6caa73a)
app.py
CHANGED
@@ -32,7 +32,7 @@ def fetch_manifest(image, tag):
|
|
32 |
|
33 |
def upload_to_huggingface(repo_id, folder_path):
|
34 |
api = HfApi(token=HF_TOKEN)
|
35 |
-
repo_path = api.create_repo(repo_id, "model", exist_ok=True
|
36 |
print(f"Repo created {repo_path}")
|
37 |
try:
|
38 |
api.upload_folder(
|
@@ -73,28 +73,28 @@ def process_image_tag(image_tag, repo_id):
|
|
73 |
download_file(config_digest, image)
|
74 |
|
75 |
# Upload to Hugging Face Hub
|
76 |
-
upload_result = upload_to_huggingface(repo_id, 'blobs
|
77 |
|
78 |
# Delete the blobs folder
|
79 |
-
|
80 |
os.rmtree('blobs')
|
81 |
return f"Successfully fetched and downloaded files for {image}:{tag}\n{upload_result}\nBlobs folder deleted"
|
82 |
except Exception as e:
|
83 |
-
os.rmtree('blobs')
|
84 |
return f"Error found: {str(e)}"
|
85 |
|
86 |
-
# Create the Gradio interface
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
)
|
|
|
98 |
|
99 |
# Launch the Gradio app
|
100 |
-
|
|
|
32 |
|
33 |
def upload_to_huggingface(repo_id, folder_path):
|
34 |
api = HfApi(token=HF_TOKEN)
|
35 |
+
repo_path = api.create_repo(repo_id, "model", exist_ok=True)
|
36 |
print(f"Repo created {repo_path}")
|
37 |
try:
|
38 |
api.upload_folder(
|
|
|
73 |
download_file(config_digest, image)
|
74 |
|
75 |
# Upload to Hugging Face Hub
|
76 |
+
upload_result = upload_to_huggingface(repo_id, 'blobs')
|
77 |
|
78 |
# Delete the blobs folder
|
|
|
79 |
os.rmtree('blobs')
|
80 |
return f"Successfully fetched and downloaded files for {image}:{tag}\n{upload_result}\nBlobs folder deleted"
|
81 |
except Exception as e:
|
82 |
+
os.rmtree('blobs', ignore_errors=True)
|
83 |
return f"Error found: {str(e)}"
|
84 |
|
85 |
+
# Create the Gradio interface using gr.Blocks
|
86 |
+
with gr.Blocks() as demo:
|
87 |
+
gr.Markdown("# Ollama <> HF Hub 🤝")
|
88 |
+
gr.Markdown("Enter the image and tag to download the corresponding files from the Ollama registry and upload them to the Hugging Face Hub.")
|
89 |
+
|
90 |
+
with gr.Row():
|
91 |
+
image_tag_input = gr.Textbox(placeholder="Enter Ollama ID", label="Image and Tag")
|
92 |
+
repo_id_input = gr.Textbox(placeholder="Enter Hugging Face repo ID", label="Hugging Face Repo ID")
|
93 |
+
|
94 |
+
result_output = gr.Textbox(label="Result")
|
95 |
+
|
96 |
+
process_button = gr.Button("Process")
|
97 |
+
process_button.click(fn=process_image_tag, inputs=[image_tag_input, repo_id_input], outputs=result_output)
|
98 |
|
99 |
# Launch the Gradio app
|
100 |
+
demo.launch()
|