kenobi commited on
Commit
ffa3cdd
1 Parent(s): 1107523

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +20 -0
README.md CHANGED
@@ -59,6 +59,26 @@ More information on the base model used can be found here: (https://huggingface.
59
 
60
  ## How to use this Model
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  ## References
63
 
64
  A publication on this work is currently in preparation. In the meantime, please refer to this model by using the following citation:
 
59
 
60
  ## How to use this Model
61
 
62
+ ```python
63
+ !pip install transformers --quiet
64
+ from transformers import AutoFeatureExtractor, AutoModelForImageClassification
65
+ from PIL import Image
66
+ import requests
67
+
68
+ url = 'https://sdo.gsfc.nasa.gov/assets/gallery/preview/211_coronalhole.jpg'
69
+ image = Image.open(requests.get(url, stream=True).raw)
70
+
71
+ feature_extractor = AutoFeatureExtractor.from_pretrained("kenobi/SDO_VT1")
72
+ model = AutoModelForImageClassification.from_pretrained("kenobi/SDO_VT1")
73
+ inputs = feature_extractor(images=image, return_tensors="pt")
74
+
75
+ outputs = model(**inputs)
76
+ logits = outputs.logits
77
+ # model predicts one of the three fine-tuned classes (NASA_SDO_Coronal_Hole, NASA_SDO_Coronal_Loop or NASA_SDO_Solar_Flare)
78
+ predicted_class_idx = logits.argmax(-1).item()
79
+ print("Predicted class:", model.config.id2label[predicted_class_idx])
80
+ ```
81
+
82
  ## References
83
 
84
  A publication on this work is currently in preparation. In the meantime, please refer to this model by using the following citation: