Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import cv2
|
|
2 |
import numpy as np
|
3 |
import torch
|
4 |
import streamlit as st
|
|
|
5 |
from transformers import AutoModelForImageClassification, AutoFeatureExtractor
|
6 |
|
7 |
# Load AI Model from Hugging Face
|
@@ -40,7 +41,7 @@ def main():
|
|
40 |
|
41 |
elif uploaded_image is not None:
|
42 |
# If an image is uploaded, process it
|
43 |
-
image = Image.open(uploaded_image)
|
44 |
image = np.array(image)
|
45 |
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
46 |
predictions = process_frame(image)
|
@@ -51,3 +52,4 @@ if __name__ == "__main__":
|
|
51 |
main()
|
52 |
|
53 |
|
|
|
|
2 |
import numpy as np
|
3 |
import torch
|
4 |
import streamlit as st
|
5 |
+
from PIL import Image # Import Image from PIL
|
6 |
from transformers import AutoModelForImageClassification, AutoFeatureExtractor
|
7 |
|
8 |
# Load AI Model from Hugging Face
|
|
|
41 |
|
42 |
elif uploaded_image is not None:
|
43 |
# If an image is uploaded, process it
|
44 |
+
image = Image.open(uploaded_image) # Use PIL.Image to open the image
|
45 |
image = np.array(image)
|
46 |
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
47 |
predictions = process_frame(image)
|
|
|
52 |
main()
|
53 |
|
54 |
|
55 |
+
|