File size: 1,835 Bytes
cbdc5ec 88775d1 cbdc5ec 66662af 75a0f13 cbdc5ec 88775d1 75a0f13 88775d1 75a0f13 88775d1 75a0f13 66662af a914fa3 ac86121 cbdc5ec cee67d6 a914fa3 cee67d6 a914fa3 cee67d6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import csv
from datetime import datetime
import os
from typing import Optional
import gradio as gr
#from convert import convert
from huggingface_hub import HfApi, Repository
# DATASET_REPO_URL = "https://huggingface.co/datasets/safetensors/conversions"
# DATA_FILENAME = "data.csv"
# DATA_FILE = os.path.join("data", DATA_FILENAME)
# HF_TOKEN = os.environ.get("HF_TOKEN")
# repo: Optional[Repository] = None
# # TODO
# if False and HF_TOKEN:
# repo = Repository(local_dir="data", clone_from=DATASET_REPO_URL, token=HF_TOKEN)
def run(model_id: str, token: Optional[str] = None) -> str:
print(model_id + ' ' + token)
return model_id + ' ' + token
DESCRIPTION = """
The steps are the following:
- Paste a read-access token from hf.co/settings/tokens. Read access is enough given that we will open a PR against the source repo.
- Input a model id from the Hub
- Click "Submit"
- That's it! You'll get feedback if it works or not, and if it worked, you'll get the URL of the opened PR 🔥
⚠️ For now only `pytorch_model.bin` files are supported but we'll extend in the future.
"""
title="Convert any model to Safetensors and open a PR"
allow_flagging="never"
with gr.Blocks(title=title) as demo:
description = gr.Markdown(f"""# {title}""")
description = gr.Markdown(DESCRIPTION)
with gr.Row() as r:
with gr.Column() as c:
model_id = gr.Text(max_lines=1, label="model_id")
token = gr.Text(max_lines=1, label="your_hf_token")
with gr.Row() as c:
clean = gr.ClearButton()
submit = gr.Button("Submit", variant="primary")
with gr.Column() as d:
output = gr.Markdown()
submit.click(run, inputs=[model_id, token], outputs=output, concurrency_limit=1)
demo.queue(max_size=10).launch(show_api=True)
|