Spaces:
Running
Running
MekkCyber
commited on
Commit
·
db371b0
1
Parent(s):
ae3cfae
update
Browse files
app.py
CHANGED
@@ -35,8 +35,10 @@ def run_inference(model_name, input_text, num_tokens=6):
|
|
35 |
try:
|
36 |
# Call the `run_inference.py` script with the model and input
|
37 |
start_time = time.time()
|
|
|
|
|
38 |
result = subprocess.run(
|
39 |
-
f"python run_inference.py -m models/
|
40 |
shell=True,
|
41 |
cwd=BITNET_REPO_PATH,
|
42 |
capture_output=True,
|
@@ -59,7 +61,8 @@ def run_transformers(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken
|
|
59 |
# Load the model and tokenizer dynamically if needed (commented out for performance)
|
60 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=oauth_token.token)
|
61 |
model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=oauth_token.token)
|
62 |
-
|
|
|
63 |
# Encode the input text
|
64 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
65 |
|
@@ -115,8 +118,8 @@ def interface():
|
|
115 |
with gr.Row():
|
116 |
transformer_model_dropdown = gr.Dropdown(
|
117 |
label="Select Transformers Model",
|
118 |
-
choices=["
|
119 |
-
value="
|
120 |
interactive=True
|
121 |
)
|
122 |
compare_button = gr.Button("Run Transformers Inference", elem_id="compare-button")
|
|
|
35 |
try:
|
36 |
# Call the `run_inference.py` script with the model and input
|
37 |
start_time = time.time()
|
38 |
+
if input_text is None :
|
39 |
+
return "Please provide an input text for the model"
|
40 |
result = subprocess.run(
|
41 |
+
f"python run_inference.py -m models/{model_name}/ggml-model-i2_s.gguf -p \"{input_text}\" -n {num_tokens} -temp 0",
|
42 |
shell=True,
|
43 |
cwd=BITNET_REPO_PATH,
|
44 |
capture_output=True,
|
|
|
61 |
# Load the model and tokenizer dynamically if needed (commented out for performance)
|
62 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=oauth_token.token)
|
63 |
model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=oauth_token.token)
|
64 |
+
if input_text is None :
|
65 |
+
return "Please provide an input text for the model", None
|
66 |
# Encode the input text
|
67 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
68 |
|
|
|
118 |
with gr.Row():
|
119 |
transformer_model_dropdown = gr.Dropdown(
|
120 |
label="Select Transformers Model",
|
121 |
+
choices=["TinyLlama/TinyLlama-1.1B-Chat-v1.0"], # Replace with actual models
|
122 |
+
value="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
|
123 |
interactive=True
|
124 |
)
|
125 |
compare_button = gr.Button("Run Transformers Inference", elem_id="compare-button")
|