File size: 1,361 Bytes
c02cd66
be71ec4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
  "model_name": "facial_emotion_simplecnn",
  "model_type": "simple_cnn",
  "framework": "pytorch",
  "task": "image-classification",

  "num_classes": 7,
  "labels": {
    "0": "angry",
    "1": "disgust",
    "2": "fear",
    "3": "happy",
    "4": "sad",
    "5": "surprise",
    "6": "neutral"
  },

  "in_channels": 1,
  "input_size": [48, 48],
  "preprocessing": {
    "resize": [48, 48],
    "normalize_mean": [0.5],
    "normalize_std": [0.5],
    "color_mode": "grayscale"
  },

  "training_dataset": "FER2013 (or similar facial emotion dataset)",
  "author": "sreenathsree1578",
  "license": "mit",

  "example_usage": "from facial_emotion import SimpleCNN\nfrom huggingface_hub import hf_hub_download\nimport torch\n\n# Load config\nimport json\nconfig = json.load(open('config.json'))\n\n# Build model\nmodel = SimpleCNN(num_classes=config['num_classes'], in_channels=config['in_channels'])\n\n# Load weights from hub\ncheckpoint = hf_hub_download(repo_id='sreenathsree1578/facial_emotion', filename='pytorch_model.bin')\nmodel.load_state_dict(torch.load(checkpoint, map_location='cpu'))\nmodel.eval()\n\n# Example inference\ntensor = torch.randn(1, 1, 48, 48)  # dummy grayscale image\nwith torch.no_grad():\n    output = model(tensor)\n    pred = torch.argmax(output, dim=1).item()\n    print('Predicted class:', config['labels'][str(pred)])"
}