macromate-pytorch-model

Integrate a PyTorch model with CLIP fallback into MacroMate detection workflows.

Updated Dec 18, 2025
One-click install
npx skills add https://github.com/renish7606/MacroMate --skill macromate-pytorch-model
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: macromate-pytorch-model
Source: https://github.com/renish7606/MacroMate/tree/main/.antigravity/skills/macromate-pytorch-model
Command: npx skills add https://github.com/renish7606/MacroMate --skill macromate-pytorch-model

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a clean path to replace the old TensorFlow/Keras final_model.h5 with a PyTorch-based best_model.pt in MacroMate, enabling an updated detection pipeline.

Core Features & Use Cases

  • Hybrid detection: prefers the custom PyTorch model for inference and falls back to CLIP for uncertain cases.
  • End-to-end integration: places new model files, rewrites detector logic, and updates nutrition lookups and UI badges to reflect the active model.
  • Use Case: Devs upgrading MacroMate to PyTorch can follow the steps to swap models, adapt file paths, and ensure results display the correct model source badge.

Quick Start

Place the three new files into the models/ folder and completely rewrite ml_food_predictor.py to load best_model.pt with torchvision, implement hybrid detection (custom PyTorch model first → CLIP fallback), and update nutrition_provider.py and UI badges to reflect the PyTorch integration.

Frequently Asked Questions about macromate-pytorch-model

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace a Keras model with a PyTorch model in a food detection pipeline?

Hybrid detection uses a custom PyTorch model for primary inference and falls back to CLIP for uncertain cases. This dual-path approach improves accuracy by leveraging a fallback mechanism when the custom model lacks confidence.

How do I update UI badges and nutrition lookups after integrating a PyTorch model?

After integrating the PyTorch model, you update the nutrition provider script and modify result.html and multi_result.html templates. This maps nutrition data correctly and displays badges reflecting the active model source.

What is the best way to handle model loading and file paths when migrating from TensorFlow to PyTorch?

The best way to handle model loading is to completely rewrite the predictor script to use torchvision for loading the .pt file. You must also adapt file paths to point to the new PyTorch model files in the models directory.

Does the hybrid detection approach work for uncertain food classifications?

Yes, hybrid detection is specifically designed for uncertain food classifications by falling back to CLIP. When the custom PyTorch model is uncertain about a prediction, the system automatically routes the inference to CLIP.