Dave-A commited on
Commit
4577277
·
1 Parent(s): f6cd1c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -1,14 +1,15 @@
1
- #import streamlit as st
 
2
  from io import StringIO
3
  from PIL import Image
4
  import pandas as pd
5
  import numpy as np
6
- import glob
7
- import os
8
 
9
  import torch
10
  import torch.nn as nn
11
- from torch.utils.data import Dataset, DataLoader
12
  import torchvision.models as models
13
  #from torchinfo import summary
14
 
@@ -18,14 +19,14 @@ import torchvision.models as models
18
  #from tqdm import tqdm
19
  #import opencv-python
20
  import cv2
21
- #import albumentations as A # Albumentations is a computer vision tool that boosts the performance of deep convolutional neural networks. (https://albumentations.ai/)
22
  #import matplotlib.pyplot as plt
23
  #import seaborn as sns
24
- #from albumentations.pytorch.transforms import ToTensorV2
25
 
26
  model = models.resnet50(pretrained=False)
27
  model.fc = nn.Linear(2048, num_classes)
28
- model.load_state_dict(torch.load('resnet_best.pth'), strict=True)
29
 
30
  st.title("some big ML function")
31
 
@@ -33,8 +34,9 @@ uploaded_file = st.file_uploader("Choose a file")
33
 
34
  if uploaded_file is not None:
35
  if ".jpg" in uploaded_file.name or ".png" in uploaded_file.name:
36
- image = Image.open(uploaded_file)
37
- st.image(image) #show it
 
38
 
39
  elif ".csv" in uploaded_file.name:
40
  dataframe = pd.read_csv(uploaded_file)
 
1
+ from distutils.command.upload import upload
2
+ import streamlit as st
3
  from io import StringIO
4
  from PIL import Image
5
  import pandas as pd
6
  import numpy as np
7
+ #import glob
8
+ #import os
9
 
10
  import torch
11
  import torch.nn as nn
12
+ #from torch.utils.data import Dataset, DataLoader
13
  import torchvision.models as models
14
  #from torchinfo import summary
15
 
 
19
  #from tqdm import tqdm
20
  #import opencv-python
21
  import cv2
22
+ import albumentations as A # Albumentations is a computer vision tool that boosts the performance of deep convolutional neural networks. (https://albumentations.ai/)
23
  #import matplotlib.pyplot as plt
24
  #import seaborn as sns
25
+ from albumentations.pytorch.transforms import ToTensorV2
26
 
27
  model = models.resnet50(pretrained=False)
28
  model.fc = nn.Linear(2048, num_classes)
29
+ model.load_state_dict(torch.load('resnet_best.pth', map_location=torch.device('cpu')), strict=True)
30
 
31
  st.title("some big ML function")
32
 
 
34
 
35
  if uploaded_file is not None:
36
  if ".jpg" in uploaded_file.name or ".png" in uploaded_file.name:
37
+ img = Image.open(uploaded_file)
38
+ st.image(img)
39
+ img = np.array(img)
40
 
41
  elif ".csv" in uploaded_file.name:
42
  dataframe = pd.read_csv(uploaded_file)