File size: 1,051 Bytes
20aa964
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import shutil
import subprocess
import signal
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
import gradio as gr

from huggingface_hub import create_repo, HfApi
from huggingface_hub import snapshot_download
from huggingface_hub import whoami
from huggingface_hub import ModelCard

from gradio_huggingfacehub_search import HuggingfaceHubSearch

from apscheduler.schedulers.background import BackgroundScheduler

HF_TOKEN = os.environ.get("HF_TOKEN")

HF_PATH = "https://huggingface.co/"

# change to include others
CONV_TEMPLATE = "tinyllama_v1_0"

def button_click(_, hf_model_id, quantization):
    os.system("mkdir -p dist/models && cd dist/models")
    os.system("git lfs install")
    os.system("git clone " + HF_PATH + hf_model_id)
    os.system("cd ../..")
    

    return "successful"

demo = gr.Interface(
    fn=button_click,
    inputs = [gr.Button("Click me"),
              gr.Textbox(label="HF Model ID"), 
              gr.Dropdown(["q4f16_1", "q4f32_1"], label="Quantization Method")],
    outputs = "text"
)

demo.launch()