Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,19 +2,19 @@ import gradio as gr
|
|
| 2 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
| 3 |
import requests
|
| 4 |
|
| 5 |
-
processed_inputs = {}
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
if oauth_token is None or oauth_token.token is None or profile.username is None:
|
| 9 |
-
return "
|
| 10 |
|
| 11 |
if not model_id or not q_method or not email:
|
| 12 |
-
return "
|
| 13 |
|
| 14 |
input_hash = hash((model_id, q_method, oauth_token.token, profile.username))
|
| 15 |
|
| 16 |
if input_hash in processed_inputs and processed_inputs[input_hash] == 200:
|
| 17 |
-
return "
|
| 18 |
|
| 19 |
url = "https://sdk.nexa4ai.com/task"
|
| 20 |
|
|
@@ -25,20 +25,29 @@ def process_inputs(markdown, model_id, q_method, email, oauth_token: gr.OAuthTok
|
|
| 25 |
"email": email,
|
| 26 |
"quantization_option": q_method,
|
| 27 |
}
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
response = requests.post(url, json=data)
|
| 30 |
|
| 31 |
if response.status_code == 200:
|
| 32 |
processed_inputs[input_hash] = 200
|
| 33 |
-
return "
|
| 34 |
else:
|
| 35 |
processed_inputs[input_hash] = response.status_code
|
| 36 |
-
return f"
|
| 37 |
|
| 38 |
iface = gr.Interface(
|
| 39 |
fn=process_inputs,
|
| 40 |
inputs=[
|
| 41 |
-
gr.Markdown(value="##### 🔔 You must grant access to the model repository before use."),
|
| 42 |
HuggingfaceHubSearch(
|
| 43 |
label="Hub Model ID",
|
| 44 |
placeholder="Search for model id on Huggingface",
|
|
@@ -55,17 +64,20 @@ iface = gr.Interface(
|
|
| 55 |
],
|
| 56 |
outputs = gr.Markdown(
|
| 57 |
label="output",
|
| 58 |
-
value="
|
| 59 |
),
|
| 60 |
-
title="Create your own GGUF Quants, blazingly fast ⚡!",
|
| 61 |
allow_flagging="never"
|
| 62 |
)
|
| 63 |
|
| 64 |
-
theme = gr.themes.
|
| 65 |
with gr.Blocks(theme=theme) as demo:
|
| 66 |
-
gr.
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
iface.render()
|
| 69 |
-
gr.Markdown(value="We sincerely thank our community members, [Perry](https://huggingface.co/PerryCheng614), [Brian](https://huggingface.co/JoyboyBrian), [Qi](https://huggingface.co/qiqiWav), for their extraordinary contributions to this GGUF converter project.")
|
| 70 |
|
| 71 |
-
demo.launch(share=True)
|
|
|
|
| 2 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
| 3 |
import requests
|
| 4 |
|
|
|
|
| 5 |
|
| 6 |
+
processed_inputs = {}
|
| 7 |
+
def process_inputs(model_id, q_method, email, oauth_token: gr.OAuthToken | None, profile: gr.OAuthProfile | None):
|
| 8 |
if oauth_token is None or oauth_token.token is None or profile.username is None:
|
| 9 |
+
return " You must be logged in to use this service."
|
| 10 |
|
| 11 |
if not model_id or not q_method or not email:
|
| 12 |
+
return " All fields are required!"
|
| 13 |
|
| 14 |
input_hash = hash((model_id, q_method, oauth_token.token, profile.username))
|
| 15 |
|
| 16 |
if input_hash in processed_inputs and processed_inputs[input_hash] == 200:
|
| 17 |
+
return " This request has already been submitted successfully. Please do not submit the same request multiple times."
|
| 18 |
|
| 19 |
url = "https://sdk.nexa4ai.com/task"
|
| 20 |
|
|
|
|
| 25 |
"email": email,
|
| 26 |
"quantization_option": q_method,
|
| 27 |
}
|
| 28 |
+
"""
|
| 29 |
+
# OAuth Token Information:
|
| 30 |
+
# - This is an OAuth token, not a user's password.
|
| 31 |
+
# - We need the OAuth token to clone the related repository and access its contents.
|
| 32 |
+
# - As mentioned in the README.md, only read permission is requested, which includes:
|
| 33 |
+
# - Read access to your public profile
|
| 34 |
+
# - Read access to the content of all your public repos
|
| 35 |
+
# - The token expires after 60 minutes.
|
| 36 |
+
# - For more information about OAuth, please refer to the official documentation:
|
| 37 |
+
# https://huggingface.co/docs/hub/en/spaces-oauth
|
| 38 |
+
"""
|
| 39 |
response = requests.post(url, json=data)
|
| 40 |
|
| 41 |
if response.status_code == 200:
|
| 42 |
processed_inputs[input_hash] = 200
|
| 43 |
+
return " Your request has been submitted successfully. We will notify you by email once processing is complete. There is no need to submit the same request multiple times."
|
| 44 |
else:
|
| 45 |
processed_inputs[input_hash] = response.status_code
|
| 46 |
+
return f" Failed to submit request: {response.text}"
|
| 47 |
|
| 48 |
iface = gr.Interface(
|
| 49 |
fn=process_inputs,
|
| 50 |
inputs=[
|
|
|
|
| 51 |
HuggingfaceHubSearch(
|
| 52 |
label="Hub Model ID",
|
| 53 |
placeholder="Search for model id on Huggingface",
|
|
|
|
| 64 |
],
|
| 65 |
outputs = gr.Markdown(
|
| 66 |
label="output",
|
| 67 |
+
value=" Please enter the model URL, select a quantization method, and provide your email address."
|
| 68 |
),
|
|
|
|
| 69 |
allow_flagging="never"
|
| 70 |
)
|
| 71 |
|
| 72 |
+
theme = gr.themes.Soft(text_size="lg", spacing_size="lg")
|
| 73 |
with gr.Blocks(theme=theme) as demo:
|
| 74 |
+
with gr.Row(variant="panel'"):
|
| 75 |
+
gr.Markdown(value="## 🚀 Unleash the Power of Custom GGML Quantized Models! ⚡"),
|
| 76 |
+
gr.LoginButton(min_width=380)
|
| 77 |
+
|
| 78 |
+
gr.Markdown(value="🚨 **IMPORTANT:** You **MUST** grant access to the model repository before use.")
|
| 79 |
+
gr.Markdown(value="🔔 You **MUST** be logged in to use this service.")
|
| 80 |
iface.render()
|
| 81 |
+
gr.Markdown(value="We sincerely thank our community members, [Perry](https://huggingface.co/PerryCheng614), [Brian](https://huggingface.co/JoyboyBrian), [Qi](https://huggingface.co/qiqiWav), [David](https://huggingface.co/Davidqian123), for their extraordinary contributions to this GGUF converter project.")
|
| 82 |
|
| 83 |
+
demo.launch(share=True)
|