Spaces:
Runtime error
Runtime error
Commit
·
f562da7
1
Parent(s):
eb15267
update
Browse files- __pycache__/models.cpython-310.pyc +0 -0
- app.py +38 -2
- models.py +39 -0
__pycache__/models.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/models.cpython-310.pyc and b/__pycache__/models.cpython-310.pyc differ
|
|
|
app.py
CHANGED
|
@@ -8,7 +8,10 @@ import spaces
|
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
| 10 |
from PIL import Image
|
| 11 |
-
from models import
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def progress_bar_html(label: str) -> str:
|
| 14 |
"""
|
|
@@ -228,8 +231,26 @@ examples = [
|
|
| 228 |
]
|
| 229 |
|
| 230 |
def create_interface():
|
| 231 |
-
# Get the list of available models
|
| 232 |
model_options = get_model_list()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
|
| 234 |
with gr.Blocks() as demo:
|
| 235 |
gr.Markdown("# **Qwen2.5 Series (add `@video-infer` for video understanding)**")
|
|
@@ -242,6 +263,21 @@ def create_interface():
|
|
| 242 |
label="Select Model"
|
| 243 |
)
|
| 244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
with gr.Row():
|
| 246 |
temperature = gr.Slider(
|
| 247 |
minimum=0.0,
|
|
|
|
| 8 |
import cv2
|
| 9 |
import numpy as np
|
| 10 |
from PIL import Image
|
| 11 |
+
from models import (
|
| 12 |
+
get_model_list, get_model_info, DEFAULT_GENERATION_PARAMS,
|
| 13 |
+
get_preset_list, get_preset_params, get_preset_description
|
| 14 |
+
)
|
| 15 |
|
| 16 |
def progress_bar_html(label: str) -> str:
|
| 17 |
"""
|
|
|
|
| 231 |
]
|
| 232 |
|
| 233 |
def create_interface():
|
| 234 |
+
# Get the list of available models and presets
|
| 235 |
model_options = get_model_list()
|
| 236 |
+
preset_options = get_preset_list()
|
| 237 |
+
|
| 238 |
+
def apply_preset(preset_name):
|
| 239 |
+
"""Helper function to apply parameter presets"""
|
| 240 |
+
params = get_preset_params(preset_name)
|
| 241 |
+
return [
|
| 242 |
+
params["temperature"],
|
| 243 |
+
params["top_p"],
|
| 244 |
+
params["top_k"],
|
| 245 |
+
params["max_new_tokens"],
|
| 246 |
+
params["do_sample"],
|
| 247 |
+
params["num_beams"],
|
| 248 |
+
params["early_stopping"],
|
| 249 |
+
params["length_penalty"],
|
| 250 |
+
params["no_repeat_ngram_size"],
|
| 251 |
+
params["repetition_penalty"],
|
| 252 |
+
get_preset_description(preset_name)
|
| 253 |
+
]
|
| 254 |
|
| 255 |
with gr.Blocks() as demo:
|
| 256 |
gr.Markdown("# **Qwen2.5 Series (add `@video-infer` for video understanding)**")
|
|
|
|
| 263 |
label="Select Model"
|
| 264 |
)
|
| 265 |
|
| 266 |
+
with gr.Row():
|
| 267 |
+
preset_dropdown = gr.Dropdown(
|
| 268 |
+
choices=preset_options,
|
| 269 |
+
value="Default",
|
| 270 |
+
label="Parameter Preset"
|
| 271 |
+
)
|
| 272 |
+
preset_description = gr.Textbox(
|
| 273 |
+
value=get_preset_description("Default"),
|
| 274 |
+
label="Preset Description",
|
| 275 |
+
interactive=False
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
# Button to apply the selected preset
|
| 279 |
+
preset_button = gr.Button("Apply Preset")
|
| 280 |
+
|
| 281 |
with gr.Row():
|
| 282 |
temperature = gr.Slider(
|
| 283 |
minimum=0.0,
|
models.py
CHANGED
|
@@ -105,3 +105,42 @@ def get_model_list():
|
|
| 105 |
list: List of model names
|
| 106 |
"""
|
| 107 |
return list(RECOMMENDED_MODELS.keys())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
list: List of model names
|
| 106 |
"""
|
| 107 |
return list(RECOMMENDED_MODELS.keys())
|
| 108 |
+
|
| 109 |
+
def get_preset_list():
|
| 110 |
+
"""
|
| 111 |
+
Returns a list of available parameter presets.
|
| 112 |
+
|
| 113 |
+
Returns:
|
| 114 |
+
list: List of preset names
|
| 115 |
+
"""
|
| 116 |
+
return list(GENERATION_PRESETS.keys())
|
| 117 |
+
|
| 118 |
+
def get_preset_params(preset_name):
|
| 119 |
+
"""
|
| 120 |
+
Returns the generation parameters for a given preset.
|
| 121 |
+
|
| 122 |
+
Args:
|
| 123 |
+
preset_name (str): Name of the preset
|
| 124 |
+
|
| 125 |
+
Returns:
|
| 126 |
+
dict: Generation parameters
|
| 127 |
+
"""
|
| 128 |
+
return GENERATION_PRESETS.get(preset_name, DEFAULT_GENERATION_PARAMS)
|
| 129 |
+
|
| 130 |
+
def get_preset_description(preset_name):
|
| 131 |
+
"""
|
| 132 |
+
Returns a description for the given preset.
|
| 133 |
+
|
| 134 |
+
Args:
|
| 135 |
+
preset_name (str): Name of the preset
|
| 136 |
+
|
| 137 |
+
Returns:
|
| 138 |
+
str: Description of the preset
|
| 139 |
+
"""
|
| 140 |
+
descriptions = {
|
| 141 |
+
"Default": "Balanced parameters suitable for most use cases",
|
| 142 |
+
"Creative": "Higher temperature and diversity for more creative outputs",
|
| 143 |
+
"Precise": "Lower temperature with beam search for more precise, focused responses",
|
| 144 |
+
"Deterministic": "Greedy decoding with beam search for deterministic, consistent outputs"
|
| 145 |
+
}
|
| 146 |
+
return descriptions.get(preset_name, "Custom parameters")
|