--- title: isHotdog emoji: 🌭 colorFrom: yellow colorTo: red sdk: gradio sdk_version: 5.49.1 app_file: app.py python_version: 3.12 pinned: false license: mit --- # isHotdog isHotdog is a small MobileNetV3 image classifier inspired by the Silicon Valley "Hotdog / Not Hotdog" joke. It answers one question: ```text Hotdog Not Hotdog ``` ## Project Structure ```text hotvision/ app.py Gradio UI hotvision_model.py model loading and prediction logic prepare_data.py creates Food-101 binary dataset train.py trains MobileNetV3 Small predict.py CLI prediction requirements.txt dependencies README.md internal project notes ``` Generated local folders: ```text dataset/ prepared train/val image-folder dataset raw_data/ Food-101 cache model/isHotdog.pt trained model checkpoint photos/ local test images ``` ## Install ```bash cd models/hotvision python3.12 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ## Prepare Dataset isHotdog can use three sources: - Food-101: `hot_dog` as `Hotdog`, selected other foods as `Not Hotdog` - `antareepdey/Hotdog-or-not-a-hotdog`: local hotdog / others images - `hotdog-nothotdog`: local train/test hotdog / nothotdog images - `bghira/not-a-hotdog`: hard negative not-hotdog images Your downloaded Hugging Face datasets should be here: ```text datasets/ datasets--antareepdey--Hotdog-or-not-a-hotdog/ datasets--bghira--not-a-hotdog/ hotdog-nothotdog/ ``` Prepare the best mixed dataset: ```bash python prepare_data.py --overwrite ``` Prepare only from the local Hugging Face datasets, without downloading Food-101: ```bash python prepare_data.py --overwrite --no-food101 ``` Use all bghira hard negatives instead of the default quick subset: ```bash python prepare_data.py --overwrite --no-food101 --max-bghira 0 ``` Output: ```text dataset/train/hotdog dataset/train/not_hotdog dataset/val/hotdog dataset/val/not_hotdog ``` Recommended: use the mixed dataset if you can download Food-101. Use local-only if you want the fastest setup with the datasets already downloaded. ## Train ```bash python train.py --epochs 8 --batch 32 ``` On macOS the default uses `--num-workers 0` because it is the most stable option with local functions and Python multiprocessing. If training on CPU, use a smaller batch: ```bash python train.py --epochs 8 --batch 16 ``` If pretrained MobileNetV3 weights cannot be downloaded, train from scratch: ```bash python train.py --epochs 12 --batch 16 --no-pretrained ``` The model is saved to: ```text model/isHotdog.pt ``` ## CLI Prediction Put images into: ```text photos/ ``` Run: ```bash python predict.py ``` Or run one image: ```bash python predict.py path/to/image.jpg ``` Example output: ```text test.jpg: ✅ Hotdog confidence=94.20% hotdog_probability=94.20% ``` ## Web App ```bash python app.py ``` The interface shows: ```text ✅ Hotdog ``` or: ```text ❌ Not Hotdog ``` ## Threshold Default threshold: ```text 0.60 ``` Meaning: isHotdog says `Hotdog` only if hotdog probability is at least 60%. Use a stricter threshold for fewer false hotdogs: ```bash python predict.py photo.jpg --threshold 0.75 ``` ## Notes - This is a classifier, not object detection. - It does not draw boxes because the task only needs binary image-level output. - MobileNetV3 Small is used because it is light, fast, and good enough for this joke/product. - Do not commit `dataset/`, `raw_data/`, `model/`, `runs/`, or local photos.