SolubleFish commited on
Commit
a7a1de1
1 Parent(s): 763de71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -3,8 +3,9 @@ from transformers import pipeline
3
  from PIL import Image
4
  import requests
5
  from io import BytesIO
 
6
 
7
-
8
  # Title
9
  st.title("Image Classification Web App")
10
  st.markdown("This app uses Hugging Face's 'transformers' library to classify images using pre-trained models. The app uses three different models for image classification: swin, convnext and vit. Please select a model to classify the image you put on the left sidebar.")
@@ -37,13 +38,13 @@ st.sidebar.markdown("*Swin Transformer* https://huggingface.co/docs/transformers
37
  # Image classification function
38
 
39
  def classify_image1(image):
40
- pipe1 = pipeline("image-classification", "SolubleFish/swin_transformer-finetuned-eurosat")
41
  return pipe1(image)
42
  def classify_image2(image):
43
- pipe2 = pipeline("image-classification", "SolubleFish/image_classification_convnext")
44
  return pipe2(image)
45
  def classify_image3(image):
46
- pipe3 = pipeline("image-classification", "SolubleFish/image_classification_vit")
47
  return pipe3(image)
48
 
49
 
 
3
  from PIL import Image
4
  import requests
5
  from io import BytesIO
6
+ import os
7
 
8
+ hf_token = os.environ.get("HF_TOKEN")
9
  # Title
10
  st.title("Image Classification Web App")
11
  st.markdown("This app uses Hugging Face's 'transformers' library to classify images using pre-trained models. The app uses three different models for image classification: swin, convnext and vit. Please select a model to classify the image you put on the left sidebar.")
 
38
  # Image classification function
39
 
40
  def classify_image1(image):
41
+ pipe1 = pipeline("image-classification", "SolubleFish/swin_transformer-finetuned-eurosat", token=hf_token)
42
  return pipe1(image)
43
  def classify_image2(image):
44
+ pipe2 = pipeline("image-classification", "SolubleFish/image_classification_convnext", token=hf_token)
45
  return pipe2(image)
46
  def classify_image3(image):
47
+ pipe3 = pipeline("image-classification", "SolubleFish/image_classification_vit", token=hf_token)
48
  return pipe3(image)
49
 
50