Downloads · 30 days
0
sanskxr02/Visionary-Net
Visionary-Net is a machine learning model from sanskxr02. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for timm. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Dec 11, 2025
Repo size
190 MB
Likes
0
Public
Click a slice to open those files.
.pth190 MB · 100%
From the Hugging Face model README
AI-Powered Refractive Error Estimation
Visionary-Net is a deep learning model that acts as a "Neural Auto-Refractor." It analyzes blur patterns in an image to estimate the optical prescription needed to correct them.
model_v1_ep9.pth (Included in repo)You need timm, torch, and opencv-python.
import torch
import torch.nn as nn
import timm
import cv2
import numpy as np
from huggingface_hub import hf_hub_download
# 1. Define Architecture
class VisionaryNet(nn.Module):
def __init__(self):
super().__init__()
self.backbone = timm.create_model('efficientnet_b0', pretrained=False, num_classes=0)
self.head = nn.Sequential(
nn.Linear(1280, 512), nn.ReLU(), nn.Dropout(0.2), nn.Linear(512, 4)
)
def forward(self, x):
return self.head(self.backbone(x))
# 2. Load the Best Checkpoint (Epoch 9)
model_path = hf_hub_download(repo_id="sanskxr02/Visionary-Net", filename="model_v1_ep9.pth")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = VisionaryNet().to(device)
model.load_state_dict(torch.load(model_path, map_location=device))
model.eval()
# 3. Predict on an Image
img = cv2.imread("test_blur.jpg") # Load image
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # Convert to RGB
img = cv2.resize(img, (224, 224)) / 255.0 # Resize & Normalize
img_t = torch.from_numpy(img).permute(2, 0, 1).unsqueeze(0).float().to(device)
with torch.no_grad():
preds = model(img_t)[0].cpu().numpy()
sph, cyl, sin_a, cos_a = preds
axis = np.degrees(np.arctan2(sin_a, cos_a)) / 2.0
if axis < 0: axis += 180
print(f"👁️ Prescription: SPH {sph:.2f} D | CYL {cyl:.2f} D | AXIS {axis:.0f}°")