Instructions to use ReFocus/Trained_Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ReFocus/Trained_Model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ReFocus/Trained_Model")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ReFocus/Trained_Model", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ReFocus/Trained_Model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ReFocus/Trained_Model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ReFocus/Trained_Model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ReFocus/Trained_Model
- SGLang
How to use ReFocus/Trained_Model with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ReFocus/Trained_Model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ReFocus/Trained_Model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ReFocus/Trained_Model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ReFocus/Trained_Model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ReFocus/Trained_Model with Docker Model Runner:
docker model run hf.co/ReFocus/Trained_Model
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# <img src="assets/icon.png" width="35" /> ReFocus
|
| 2 |
+
|
| 3 |
+
This repo contains the model for the paper "ReFocus: Visual Editing as a Chain of Thought for Structured Image Understanding"
|
| 4 |
+
|
| 5 |
+
[**🌐 Homepage**](https://zeyofu.github.io/ReFocus/) |[**📑 Paper**](https://arxiv.org/abs/2501.05452) | [**🔗 Code**](https://github.com/zeyofu/ReFocus_Code)
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
# Introduction
|
| 9 |
+
|
| 10 |
+

|
| 11 |
+
|
| 12 |
+
# ReFocus Finetuning
|
| 13 |
+
We follow the [Phi-3 Cookbook](https://github.com/microsoft/Phi-3CookBook/blob/main/md/04.Fine-tuning/FineTuning_Vision.md) for the supervised finetuning experiments.
|
| 14 |
+
|
| 15 |
+
## Inference with the Finetuned Model
|
| 16 |
+
We release our best finetuned ReFocus model with full chain-of-thought data in this [HuggingFace Link](https://huggingface.co/Fiaa/ReFocus).
|
| 17 |
+
|
| 18 |
+
This model is finetuned based on Phi-3.5-vision, and we used the following prompt during evaluation
|
| 19 |
+
```
|
| 20 |
+
<|image|>\n{question}\nThought:
|
| 21 |
+
```
|
| 22 |
+
To enforce the model to generate bounding box coordinates to refocus, you could try this prompt:
|
| 23 |
+
```
|
| 24 |
+
<|image_1|>\n{question}\nThought: The areas to focus on in the image have bounding box coordinates:
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
license: apache-2.0
|
| 29 |
+
---
|