File size: 1,359 Bytes
4577277
 
ee8a448
 
 
fea3a1e
4577277
 
fea3a1e
 
 
4577277
5dd0274
ee1b10f
fea3a1e
ee1b10f
 
fea3a1e
fd651b5
f37d0b8
 
4577277
fd651b5
 
4577277
ee8a448
67d2f1c
a326ae9
4577277
67d2f1c
ee8a448
 
 
 
 
 
4577277
 
 
a326ae9
ee8a448
 
 
 
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
from distutils.command.upload import upload
import streamlit as st
from io import StringIO
from PIL import Image
import pandas as pd
import numpy as np
#import glob
#import os

import torch
import torch.nn as nn
#from torch.utils.data import Dataset, DataLoader
import torchvision.models as models
#from torchinfo import summary

#from sklearn.model_selection import StratifiedKFold
#from sklearn.metrics import accuracy_score

#from tqdm import tqdm
#import opencv-python
import cv2
import albumentations as A # Albumentations is a computer vision tool that boosts the performance of deep convolutional neural networks. (https://albumentations.ai/)
#import matplotlib.pyplot as plt
#import seaborn as sns
from albumentations.pytorch.transforms import ToTensorV2

model = models.resnet50(pretrained=False)
model.fc = nn.Linear(2048, 21)
model.load_state_dict(torch.load('resnet_best.pth', map_location=torch.device('cpu')), strict=True)

st.title("some big ML function")

uploaded_file = st.file_uploader("Choose a file")

if uploaded_file is not None:
  if ".jpg" in uploaded_file.name or ".png" in uploaded_file.name:
    img = Image.open(uploaded_file)
    st.image(img)
    img = np.array(img)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    
  elif ".csv" in uploaded_file.name:
    dataframe = pd.read_csv(uploaded_file)
    st.write(dataframe)