File size: 1,465 Bytes
66662af |
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 |
import gradio as gr
from convert import convert
def run(token: str, model_id: str) -> str:
if token == "" or model_id == "":
return """
### Invalid input 🐞
Please fill a token and model_id.
"""
try:
pr_url = convert(token=token, model_id=model_id)
return f"""
### Success 🔥
Yay! This model was successfully converted and a PR was open using your token, here:
{pr_url}
"""
except Exception as e:
return f"""
### Error 😢😢😢
{e}
"""
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.
"""
demo = gr.Interface(
title="Convert any model to Safetensors and open a PR",
description=DESCRIPTION,
allow_flagging="never",
article="Check out the [Safetensors repo on GitHub](https://github.com/huggingface/safetensors)",
inputs=[
gr.Text(max_lines=1, label="your_hf_token"),
gr.Text(max_lines=1, label="model_id"),
],
outputs=[gr.Markdown(label="output")],
fn=run,
)
demo.launch()
|