File size: 871 Bytes
1ba3e62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
tags:
- svm
- computer-vision
- image-classification
---

# SVM-VGG Image Classifier

A hybrid SVM model using VGG-based CNN features for image classification of 28 chart/scientific diagram types.

## Usage

```python
from huggingface_hub import hf_hub_download
import joblib
import torch
from torchvision.models import vgg16
from PIL import Image
import numpy as np

# Load model
model_path = hf_hub_download(repo_id="ApostolosK/svm-vgg-model", filename="model.pkl")
svm_model = joblib.load(model_path)

# Load label names
labels = [...]  # Load from labels.json

vgg_model = vgg16(pretrained=True)
fc_cnn_model = vgg_model.classifier[:-2] 
def extract_features(image_path):
    return combined_features

# Make prediction
image = Image.open("your-image.png")
features = extract_features(image)
prediction = svm_model.predict([features])[0]
print(labels[prediction])