Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ DTYPE = (
|
|
| 32 |
)
|
| 33 |
|
| 34 |
MODEL_NAME = "Qwen/Qwen3.5-2B"
|
| 35 |
-
CATEGORIES =["Query", "Caption", "Point", "Detect"]
|
| 36 |
|
| 37 |
print(f"Loading model: {MODEL_NAME} on {DEVICE}...")
|
| 38 |
try:
|
|
@@ -75,10 +75,10 @@ def generate_inference_stream(image: Image.Image, category: str, prompt: str):
|
|
| 75 |
else:
|
| 76 |
full_prompt = prompt
|
| 77 |
|
| 78 |
-
messages =[
|
| 79 |
{
|
| 80 |
"role": "user",
|
| 81 |
-
"content":[
|
| 82 |
{"type": "image", "image": image},
|
| 83 |
{"type": "text", "text": full_prompt},
|
| 84 |
],
|
|
@@ -208,7 +208,7 @@ async def homepage(request: Request):
|
|
| 208 |
|
| 209 |
/* Nodes */
|
| 210 |
.node {{
|
| 211 |
-
position: absolute; width:
|
| 212 |
background: var(--node-bg); border: 1px solid var(--node-border);
|
| 213 |
border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
|
| 214 |
z-index: 10; display: flex; flex-direction: column;
|
|
@@ -244,7 +244,7 @@ async def homepage(request: Request):
|
|
| 244 |
}}
|
| 245 |
.file-upload:hover {{ border-color: var(--accent); }}
|
| 246 |
|
| 247 |
-
.img-preview {{ width: 100%; height: auto; max-height:
|
| 248 |
|
| 249 |
select, textarea {{
|
| 250 |
width: 100%; background: #121212; border: 1px solid var(--node-border);
|
|
@@ -254,11 +254,11 @@ async def homepage(request: Request):
|
|
| 254 |
select:focus, textarea:focus {{ border-color: var(--accent); }}
|
| 255 |
|
| 256 |
button {{
|
| 257 |
-
background:
|
| 258 |
padding: 10px; border-radius: 6px; font-weight: 600; font-size: 14px;
|
| 259 |
cursor: pointer; transition: background 0.2s; display: flex; justify-content: center; gap: 8px; align-items: center;
|
| 260 |
}}
|
| 261 |
-
button:hover {{ background:
|
| 262 |
button:disabled {{ background: var(--node-border); cursor: not-allowed; color: #888; }}
|
| 263 |
|
| 264 |
.output-box {{
|
|
@@ -286,7 +286,7 @@ async def homepage(request: Request):
|
|
| 286 |
|
| 287 |
<!-- Node 1: Image Input -->
|
| 288 |
<div class="node" id="node-img" style="left: 100px; top: 150px;">
|
| 289 |
-
<div class="node-header"><span>
|
| 290 |
<div class="node-body">
|
| 291 |
<div>
|
| 292 |
<label>Upload Image</label>
|
|
@@ -303,7 +303,7 @@ async def homepage(request: Request):
|
|
| 303 |
<!-- Node 2: Task Execution -->
|
| 304 |
<div class="node" id="node-task" style="left: 550px; top: 150px;">
|
| 305 |
<div class="port in" id="port-task-in" style="top: 30%;"></div>
|
| 306 |
-
<div class="node-header"><span>
|
| 307 |
<div class="node-body">
|
| 308 |
<div>
|
| 309 |
<label>Task Category</label>
|
|
@@ -319,7 +319,7 @@ async def homepage(request: Request):
|
|
| 319 |
<textarea id="promptInput" rows="4" placeholder="e.g., Count the total number of boats and describe the environment."></textarea>
|
| 320 |
</div>
|
| 321 |
<button id="runBtn">
|
| 322 |
-
<span>
|
| 323 |
<span class="loader" id="btnLoader"></span>
|
| 324 |
</button>
|
| 325 |
</div>
|
|
@@ -329,7 +329,7 @@ async def homepage(request: Request):
|
|
| 329 |
<!-- Node 3: Output Display -->
|
| 330 |
<div class="node" id="node-out" style="left: 1000px; top: 150px; width: 380px;">
|
| 331 |
<div class="port in" id="port-out-in"></div>
|
| 332 |
-
<div class="node-header"><span>
|
| 333 |
<div class="node-body">
|
| 334 |
<label>Streamed Result</label>
|
| 335 |
<div class="output-box" id="outputBox">Results will stream here...</div>
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
MODEL_NAME = "Qwen/Qwen3.5-2B"
|
| 35 |
+
CATEGORIES = ["Query", "Caption", "Point", "Detect"]
|
| 36 |
|
| 37 |
print(f"Loading model: {MODEL_NAME} on {DEVICE}...")
|
| 38 |
try:
|
|
|
|
| 75 |
else:
|
| 76 |
full_prompt = prompt
|
| 77 |
|
| 78 |
+
messages = [
|
| 79 |
{
|
| 80 |
"role": "user",
|
| 81 |
+
"content": [
|
| 82 |
{"type": "image", "image": image},
|
| 83 |
{"type": "text", "text": full_prompt},
|
| 84 |
],
|
|
|
|
| 208 |
|
| 209 |
/* Nodes */
|
| 210 |
.node {{
|
| 211 |
+
position: absolute; width: 340px;
|
| 212 |
background: var(--node-bg); border: 1px solid var(--node-border);
|
| 213 |
border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
|
| 214 |
z-index: 10; display: flex; flex-direction: column;
|
|
|
|
| 244 |
}}
|
| 245 |
.file-upload:hover {{ border-color: var(--accent); }}
|
| 246 |
|
| 247 |
+
.img-preview {{ width: 100%; height: auto; max-height: 280px; object-fit: contain; border-radius: 4px; display: none; margin-top: 10px; background: #000; }}
|
| 248 |
|
| 249 |
select, textarea {{
|
| 250 |
width: 100%; background: #121212; border: 1px solid var(--node-border);
|
|
|
|
| 254 |
select:focus, textarea:focus {{ border-color: var(--accent); }}
|
| 255 |
|
| 256 |
button {{
|
| 257 |
+
background: #ff69b4; color: #fff; border: none;
|
| 258 |
padding: 10px; border-radius: 6px; font-weight: 600; font-size: 14px;
|
| 259 |
cursor: pointer; transition: background 0.2s; display: flex; justify-content: center; gap: 8px; align-items: center;
|
| 260 |
}}
|
| 261 |
+
button:hover {{ background: #ff1493; }}
|
| 262 |
button:disabled {{ background: var(--node-border); cursor: not-allowed; color: #888; }}
|
| 263 |
|
| 264 |
.output-box {{
|
|
|
|
| 286 |
|
| 287 |
<!-- Node 1: Image Input -->
|
| 288 |
<div class="node" id="node-img" style="left: 100px; top: 150px;">
|
| 289 |
+
<div class="node-header"><span>Input Node</span><span>ID: 01</span></div>
|
| 290 |
<div class="node-body">
|
| 291 |
<div>
|
| 292 |
<label>Upload Image</label>
|
|
|
|
| 303 |
<!-- Node 2: Task Execution -->
|
| 304 |
<div class="node" id="node-task" style="left: 550px; top: 150px;">
|
| 305 |
<div class="port in" id="port-task-in" style="top: 30%;"></div>
|
| 306 |
+
<div class="node-header"><span>Task Node</span><span>ID: 02</span></div>
|
| 307 |
<div class="node-body">
|
| 308 |
<div>
|
| 309 |
<label>Task Category</label>
|
|
|
|
| 319 |
<textarea id="promptInput" rows="4" placeholder="e.g., Count the total number of boats and describe the environment."></textarea>
|
| 320 |
</div>
|
| 321 |
<button id="runBtn">
|
| 322 |
+
<span>Quick Execution</span>
|
| 323 |
<span class="loader" id="btnLoader"></span>
|
| 324 |
</button>
|
| 325 |
</div>
|
|
|
|
| 329 |
<!-- Node 3: Output Display -->
|
| 330 |
<div class="node" id="node-out" style="left: 1000px; top: 150px; width: 380px;">
|
| 331 |
<div class="port in" id="port-out-in"></div>
|
| 332 |
+
<div class="node-header"><span>Output Node</span><span>ID: 03</span></div>
|
| 333 |
<div class="node-body">
|
| 334 |
<label>Streamed Result</label>
|
| 335 |
<div class="output-box" id="outputBox">Results will stream here...</div>
|