Spaces:
Sleeping
Sleeping
dragonjump
commited on
Commit
·
0f6bee9
1
Parent(s):
2a4f1d3
update
Browse files- README.md +46 -0
- __pycache__/main.cpython-312.pyc +0 -0
- main.py +22 -0
README.md
CHANGED
|
@@ -9,3 +9,49 @@ license: apache-2.0
|
|
| 9 |
---
|
| 10 |
|
| 11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
curl -G "https://lseanlon-qwen25-api.hf.space/predict" \
|
| 15 |
+
--data-urlencode "image_url=https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg" \
|
| 16 |
+
--data-urlencode "prompt=Describe this image."
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
curl -G "https://lseanlon-qwen25-api.hf.space/" \
|
| 24 |
+
--data-urlencode "image_url=https://huggingface.co/front/assets/huggingface_logo-noborder.svg" \
|
| 25 |
+
--data-urlencode "prompt=Describe this image."
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
curl -G "https://lseanlon-qwen25-api.hf.space/predict" \
|
| 29 |
+
--data-urlencode "image_url=https://images.all-free-download.com/images/thumbjpg/cat_hangover_relax_213869.jpg" \
|
| 30 |
+
--data-urlencode "prompt=Describe this image."
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
curl -G "https://lseanlon-qwen25-api.hf.space/predict" \
|
| 35 |
+
--data-urlencode "prompt=why is the sky blue?"
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
FROM qwen2.5-coder:7b
|
| 41 |
+
PARAMETER num_ctx 48000
|
| 42 |
+
|
| 43 |
+
ollama create -f ZModelfile qwen2.5:latest-custom
|
| 44 |
+
|
| 45 |
+
curl http://localhost:11434/api/chat -d '{
|
| 46 |
+
"model": "qwen2.5:latest",
|
| 47 |
+
"messages": [
|
| 48 |
+
{ "role": "user", "content": "why is the sky blue?" }
|
| 49 |
+
]
|
| 50 |
+
}'
|
| 51 |
+
|
| 52 |
+
curl https://dry-taxes-fold.loca.lt/api/chat -d '{
|
| 53 |
+
"model": "qwen2.5:latest",
|
| 54 |
+
"messages": [
|
| 55 |
+
{ "role": "user", "content": "why is the sky blue?" }
|
| 56 |
+
]
|
| 57 |
+
}'
|
__pycache__/main.cpython-312.pyc
ADDED
|
Binary file (2.64 kB). View file
|
|
|
main.py
CHANGED
|
@@ -46,3 +46,25 @@ def predict(image_url: str = Query(...), prompt: str = Query(...)):
|
|
| 46 |
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 47 |
)
|
| 48 |
return {"response": output_texts[0]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 47 |
)
|
| 48 |
return {"response": output_texts[0]}
|
| 49 |
+
|
| 50 |
+
@app.get("/chat")
|
| 51 |
+
def chat( prompt: str = Query(...)):
|
| 52 |
+
messages = [
|
| 53 |
+
{"role": "system", "content": "You are a helpful assistant with vision abilities."},
|
| 54 |
+
{"role": "user", "content": [ {"type": "text", "text": prompt}]},
|
| 55 |
+
]
|
| 56 |
+
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 57 |
+
video_inputs = process_vision_info(messages)
|
| 58 |
+
inputs = processor(
|
| 59 |
+
text=[text],
|
| 60 |
+
videos=video_inputs,
|
| 61 |
+
padding=True,
|
| 62 |
+
return_tensors="pt",
|
| 63 |
+
).to(model.device)
|
| 64 |
+
with torch.no_grad():
|
| 65 |
+
generated_ids = model.generate(**inputs, max_new_tokens=128)
|
| 66 |
+
generated_ids_trimmed = [out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]
|
| 67 |
+
output_texts = processor.batch_decode(
|
| 68 |
+
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 69 |
+
)
|
| 70 |
+
return {"response": output_texts[0]}
|