Run this model with HF Jobs
Run zhangyijing/mineral-bubble-models on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/zhangyijing/mineral-bubble-models. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/zhangyijing/mineral-bubble-models on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use zhangyijing/mineral-bubble-models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use zhangyijing/mineral-bubble-models with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("zhangyijing/mineral-bubble-models", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
Flotation froth instance segmentation
Inference weights for the public froth experiments: grouped training seeds 0, 1 and 2, seed-0 adaptation controls, and the index-blocked sensitivity experiment. The industrial transfer weights and images are not part of this release. Model files contain tensors, not training objects, optimizer states or machine-specific paths.
| Method | Entry point | Weights |
|---|---|---|
| Detector-guided SAM-LoRA | infer.py --model yp-single or yp-multi |
YOLOv8n, SAM ViT-B and LoRA adapter |
| Automatic SAM-LoRA | amg32, amg64 |
Same SAM and adapter, no detector |
| Frozen SAM control | frozen-amg32 |
SAM ViT-B only |
| YOLO segmentation | yolov8n, yolov8s |
Corresponding YOLO architecture JSON and safetensors |
| Topographic watershed | watershed |
No weights; fixed validation-selected settings |
| QueryInst-500 | queryinst.py, separate MMDetection environment |
QueryInst-500 state dict, seed 0, epoch 34 |
| Frozen EdgeSAM, MobileSAM and FastSAM-x | references.py --model edgesam, mobilesam or fastsam |
Original upstream checkpoints; no froth-specific training |
Run one image
Use Python 3.10+ and install a compatible PyTorch/torchvision pair (PyTorch 2.4+). Download inference files and the reviewed example images:
hf download zhangyijing/mineral-bubble-models --local-dir models --exclude "browser/*" --exclude "weights/*/*" --exclude "weights/queryinst500.safetensors"
hf download zhangyijing/mineral-bubble-segmentation --type dataset --local-dir data
python -m pip install -r models/requirements.txt
python models/infer.py data/images/image_0026_jpg.rf.8feb3a355da01da1bf739becab899346.jpg --model yp-single --output predictions.json
Weights are resolved relative to the code, not the current working directory. Set FROTH_WEIGHTS to override the weights directory. SAM modes fetch the common SAM ViT-B backbone on first use and verify its SHA-256; set SAM_CHECKPOINT to a local copy for offline use. Use --device cuda for GPU inference. The input is an image, not a ground-truth file. The output contains native-size COCO RLE masks for that image (image_id=1); learned predictions include scores. Watershed has no confidence scores.
The portable Python runner uses FP32. Its elapsed time is not the study's mixed-precision, bit-packed GPU benchmark. For 640 x 480 inputs, packed_gpu.py provides the GPU multi-output path; it also requires CUDA, NVRTC, and a compatible CuPy installation.
Optional QueryInst baseline
For a different grouped training seed, fetch its detector and adapter with hf download zhangyijing/mineral-bubble-models weights/seed1/yolov8n.safetensors weights/seed1/sam_lora.safetensors --local-dir models and pass --seed 1 to the inference runner. Use seed2 and --seed 2 for the third run. For ablations download weights/ablations/*; for the split sensitivity analysis download weights/index_blocked/*.
Use a separate environment with MMDetection 3.x and its compatible MMCV operators, MMEngine, safetensors and pycocotools. Download weights/queryinst500.safetensors into the same model directory. Run python models/queryinst.py IMAGE --device cuda:0 --output query.json. Only inference settings are included, not the training environment. This model is not loaded in the browser.
Optional frozen references
Install the relevant upstream implementation and obtain its original checkpoint: EdgeSAM (edge_sam.pth, not the 3x variant), MobileSAM (mobile_sam.pt), or FastSAM (FastSAM-x.pt, run with Ultralytics). Use a separate environment for EdgeSAM or MobileSAM if their dependencies conflict. The runner verifies the checkpoint's SHA-256 before loading it.
python models/references.py IMAGE --model fastsam --checkpoint /path/to/FastSAM-x.pt --output masks.json
MobileSAM was checked with timm==0.4.12. The EdgeSAM package also imports MMDetection and MMEngine; use the complete upstream environment, not the core requirements alone.
Browser and data
Interactive Space · Reviewed 16-image subset and full-set request instructions. Browser ONNX graphs are separate from the native weights. Both YP modes support 32 or 128 detector proposals, or their full proposal budget (512 single, 1000 multi). The browser uses a display confidence filter and is not the paper's evaluation.
To regenerate browser graphs, install ONNX and ONNX Runtime, then run python models/export_browser.py --output models/browser and python models/export_multi.py (opset 17). Both exporters check graph outputs against PyTorch. The multi-output graph checks the box-plus-center and center-only branches separately.
Software and terms
SAM code and the common backbone are from Meta's Segment Anything, licensed under Apache-2.0. YOLOv8 uses Ultralytics; the YOLO-derived weights and the combined inference application are distributed under AGPL-3.0. License texts are in licenses/. QueryInst runs on MMDetection; its compiled operators and upstream models are not bundled.