Image-Text-to-Text
PEFT
Safetensors
Korean
lora
vision
image-classification
vision-language
korean
pest-detection
agriculture
qwen
qwen3.5
unsloth
multimodal
conversational
Eval Results (legacy)
Instructions to use pfox1995/pest-detector-deploy with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use pfox1995/pest-detector-deploy with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen3.5-9B") model = PeftModel.from_pretrained(base_model, "pfox1995/pest-detector-deploy") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use pfox1995/pest-detector-deploy with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pfox1995/pest-detector-deploy to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for pfox1995/pest-detector-deploy to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for pfox1995/pest-detector-deploy to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="pfox1995/pest-detector-deploy", max_seq_length=2048, )
Add restart_server.sh (server.py + restart_server.sh + Korean README expansion)
Browse files- restart_server.sh +90 -0
restart_server.sh
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# One-shot rehydrate + relaunch for the Korean pest-detector server.
|
| 3 |
+
# Idempotent: skips installs if the packages are already importable.
|
| 4 |
+
# Run this after any pod restart (which wipes the container disk).
|
| 5 |
+
#
|
| 6 |
+
# Usage: bash /workspace/restart_server.sh
|
| 7 |
+
set -uo pipefail
|
| 8 |
+
|
| 9 |
+
PORT="${PORT:-8080}"
|
| 10 |
+
ADAPTER="${ADAPTER:-pfox1995/pest-detector-deploy}"
|
| 11 |
+
LOAD_IN_4BIT="${LOAD_IN_4BIT:-true}"
|
| 12 |
+
# RunPod auto-sets RUNPOD_POD_ID β derive proxy URL from it. Override with PUBLIC_URL=...
|
| 13 |
+
PUBLIC_URL="${PUBLIC_URL:-https://${RUNPOD_POD_ID:-YOUR_POD_ID}-${PORT}.proxy.runpod.net}"
|
| 14 |
+
|
| 15 |
+
cd /workspace
|
| 16 |
+
mkdir -p /workspace/.tmp /workspace/.pip-cache
|
| 17 |
+
export TMPDIR=/workspace/.tmp
|
| 18 |
+
|
| 19 |
+
step() { echo; echo "=== $* ==="; }
|
| 20 |
+
|
| 21 |
+
# βββββββββ Stage 1: stack βββββββββ
|
| 22 |
+
step "1/3 Python stack"
|
| 23 |
+
need_stack=0
|
| 24 |
+
python3 -c "import unsloth, peft, fastapi, uvicorn, bitsandbytes, fla" 2>/dev/null || need_stack=1
|
| 25 |
+
|
| 26 |
+
if [ $need_stack -eq 1 ]; then
|
| 27 |
+
echo " installing unsloth + transformers + peft + fastapi + bnb + fla"
|
| 28 |
+
pip install --break-system-packages --cache-dir=/workspace/.pip-cache \
|
| 29 |
+
'unsloth[cu128-torch280]' 'transformers>=5.2,<6.0' 'peft==0.19.1' \
|
| 30 |
+
fastapi uvicorn python-multipart bitsandbytes flash-linear-attention \
|
| 31 |
+
2>&1 | tail -3
|
| 32 |
+
else
|
| 33 |
+
echo " β already installed"
|
| 34 |
+
fi
|
| 35 |
+
|
| 36 |
+
# βββββββββ Stage 2: causal_conv1d (prebuilt wheel β skip the 9-arch CUDA build) βββββββββ
|
| 37 |
+
step "2/3 causal_conv1d fast-path lib"
|
| 38 |
+
if python3 -c "import causal_conv1d" 2>/dev/null; then
|
| 39 |
+
echo " β already installed: $(python3 -c 'import causal_conv1d; print(causal_conv1d.__version__)')"
|
| 40 |
+
else
|
| 41 |
+
echo " installing prebuilt wheel for torch 2.8 + cu12 + py312"
|
| 42 |
+
pip install --break-system-packages \
|
| 43 |
+
'https://github.com/Dao-AILab/causal-conv1d/releases/download/v1.6.1.post4/causal_conv1d-1.6.1%2Bcu12torch2.8cxx11abiTRUE-cp312-cp312-linux_x86_64.whl' \
|
| 44 |
+
2>&1 | tail -3
|
| 45 |
+
python3 -c "import causal_conv1d; print(' β ccc', causal_conv1d.__version__)"
|
| 46 |
+
fi
|
| 47 |
+
|
| 48 |
+
# βββββββββ Stage 3: launch server in tmux βββββββββ
|
| 49 |
+
step "3/3 launch server in tmux 'pest' on :$PORT"
|
| 50 |
+
tmux kill-session -t pest 2>/dev/null || true
|
| 51 |
+
sleep 1
|
| 52 |
+
|
| 53 |
+
tmux new-session -d -s pest "
|
| 54 |
+
export HF_TOKEN=\$(cat /workspace/.cache/huggingface/token)
|
| 55 |
+
export HF_HOME=/workspace/.cache/huggingface
|
| 56 |
+
export ADAPTER='$ADAPTER'
|
| 57 |
+
export LOAD_IN_4BIT='$LOAD_IN_4BIT'
|
| 58 |
+
export PORT='$PORT'
|
| 59 |
+
python3 -u /workspace/deploy/server.py 2>&1 | tee /workspace/pest_server.log
|
| 60 |
+
exec bash
|
| 61 |
+
"
|
| 62 |
+
|
| 63 |
+
echo
|
| 64 |
+
echo " waiting for /health (Unsloth load + LoRA attach takes ~90s)..."
|
| 65 |
+
ready_after=""
|
| 66 |
+
for i in $(seq 1 90); do
|
| 67 |
+
if curl -sf -m 2 "http://localhost:$PORT/health" >/dev/null 2>&1; then
|
| 68 |
+
ready_after="$((i*2))"
|
| 69 |
+
break
|
| 70 |
+
fi
|
| 71 |
+
sleep 2
|
| 72 |
+
done
|
| 73 |
+
|
| 74 |
+
if [ -z "$ready_after" ]; then
|
| 75 |
+
echo " β server did not come up within 180s. Check:"
|
| 76 |
+
echo " tmux capture-pane -t pest -p | tail -30"
|
| 77 |
+
echo " tail -40 /workspace/pest_server.log"
|
| 78 |
+
exit 1
|
| 79 |
+
fi
|
| 80 |
+
|
| 81 |
+
echo " β ready after ${ready_after}s"
|
| 82 |
+
echo
|
| 83 |
+
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
|
| 84 |
+
echo " β pest detector server is live"
|
| 85 |
+
echo " Local: http://localhost:$PORT"
|
| 86 |
+
echo " Public: $PUBLIC_URL"
|
| 87 |
+
echo " VRAM: $(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk -F',' '{printf "%.1f / %.1f GB\n", $1/1024, $2/1024}')"
|
| 88 |
+
echo " Logs: tail -f /workspace/pest_server.log"
|
| 89 |
+
echo " Stop: tmux kill-session -t pest"
|
| 90 |
+
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
|