Downloads · 30 days
6
23% of all-time downloads
VishavGupta01/MRBEAN_Vision
MRBEAN_Vision is a machine learning model from VishavGupta01. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains the offline multi-task computer vision model for Project MRBEAN (Mobile Resilient Broadcast for Emergency Ad-hoc Networks).
Downloads · 30 days
6
23% of all-time downloads
All-time downloads
26
Public
Repo size
85.7 MB
Likes
1
Public
Click a slice to open those files.
.pth35.7 MB · 41%
From the Hugging Face model README
This repository contains the offline multi-task computer vision model for Project MRBEAN (Mobile Resilient Broadcast for Emergency Ad-hoc Networks).
Currently in its initial development phase, this lightweight model is designed to run entirely offline on Android edge devices to analyze live camera feeds, identifying both the type of disaster and the severity of the damage simultaneously.
Link: https://crisisnlp.qcri.org/medic/#:~:text=CrisisNLP,The%20dataset%20contains%2071%2C198%20images.
The vision engine utilizes a shared MobileNetV3 (Large) backbone, splitting into two distinct dense classification heads:
Disaster Types (Head 1)
Damage Severity (Head 2)
To support cross-platform development and strict mobile deployment, the model has been exported into the following formats:
best_multitask_vision_model.pth: The raw PyTorch weights for continued training or server-side inference.mrbean_tf_model/mrbean_vision_float32.tflite (12.7 MB): Standard TensorFlow Lite model for high-accuracy Android deployment.mrbean_tf_model/mrbean_vision_float16.tflite (6.39 MB): Half-precision compressed model to minimize the Flutter application bundle size.The model expects images preprocessed to match the PyTorch standard:
mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])[1, 224, 224, 3] (NHWC format)To test the mobile-ready .tflite files on a PC before integrating them into the Flutter frontend, use the following snippet. Note: Testing the float16 model on a PC requires bypassing the XNNPACK engine.
import os
os.environ["TF_LITE_DISABLE_XNNPACK"] = "1"
import numpy as np
import tensorflow as tf
from PIL import Image
# 1. Load Model
model_path = r"mrbean_tf_model\mrbean_vision_float16.tflite"
interpreter = tf.lite.Interpreter(model_path=model_path)
interpreter.allocate_tensors()
input_details = interpreter.get_input_details()[0]
output_details = interpreter.get_output_details()
# 2. Preprocess Image
def preprocess_image(image_path, expected_shape):
img = Image.open(image_path).convert('RGB').resize((224, 224))
img_array = np.array(img, dtype=np.float32) / 255.0
mean = np.array([0.485, 0.456, 0.406], dtype=np.float32)
std = np.array([0.229, 0.224, 0.225], dtype=np.float32)
img_array = (img_array - mean) / std
if expected_shape[1] == 3: # NCHW fallback
img_array = np.transpose(img_array, (2, 0, 1))
return np.expand_dims(img_array, axis=0)
# 3. Inference
input_data = preprocess_image("test_image.jpg", input_details['shape']).astype(input_details['dtype'])
interpreter.set_tensor(input_details['index'], input_data)
interpreter.invoke()
# 4. Extract Results
out_0 = interpreter.get_tensor(output_details[0]['index'])[0]
out_1 = interpreter.get_tensor(output_details[1]['index'])[0]
pred_disaster = np.argmax(out_0) if len(out_0) == 6 else np.argmax(out_1)
pred_severity = np.argmax(out_1) if len(out_0) == 6 else np.argmax(out_0)
print(f"Disaster Class ID: {pred_disaster}")
print(f"Severity Class ID: {pred_severity}")