File size: 595 Bytes
58f7873
eeae0c7
58f7873
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import streamlit as st
import torch
import os 

def getResult(filename):
  model_name='/content/yolov5/runs/train/exp/weights/best.pt'
  model = torch.hub.load( "/content/yolov5/",'custom', source='local', path = model_name, force_reload = True)
  img = "/content/"+filename+"" 
  results = model(img)
  return results

uploaded_file = st.file_uploader("Choose a image file")
if uploaded_file is not None:
  image = uploaded_file.read()
  filename = uploaded_file.name
  resulted_img = getResult(filename)
  img = st.image(resulted_img, caption='Sunrise by the mountains', use_column_width=True)