Skip to content

Commit

Permalink
upload files
Browse files Browse the repository at this point in the history
  • Loading branch information
WENDGOUNDI authored Dec 15, 2023
1 parent 35893a9 commit 572e3d3
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.dataset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Motherboard > motherboard_5
https://universe.roboflow.com/yuelin-xin/motherboard-ptxx1

Provided by a Roboflow user
License: CC BY 4.0

33 changes: 33 additions & 0 deletions README.roboflow.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

Motherboard - v13 motherboard_5
==============================

This dataset was exported via roboflow.com on February 14, 2023 at 11:35 PM GMT

Roboflow is an end-to-end computer vision platform that helps you
* collaborate with your team on computer vision projects
* collect & organize images
* understand and search unstructured image data
* annotate, and create datasets
* export, train, and deploy computer vision models
* use active learning to improve your dataset over time

For state of the art Computer Vision training notebooks you can use with this dataset,
visit https://github.com/roboflow/notebooks

To find over 100k other datasets and pre-trained models, visit https://universe.roboflow.com

The dataset includes 1015 images.
Screws are annotated in YOLOv8 format.

The following pre-processing was applied to each image:
* Auto-orientation of pixel data (with EXIF-orientation stripping)
* Resize to 1000x1000 (Stretch)
* Auto-contrast via adaptive equalization

The following augmentation was applied to create 3 versions of each source image:
* 50% probability of horizontal flip
* Equal probability of one of the following 90-degree rotations: none, clockwise, counter-clockwise
* Random exposure adjustment of between -25 and +25 percent


Binary file added best.pt
Binary file not shown.
13 changes: 13 additions & 0 deletions data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
train: "set your training data path here"
val: "set your validation data path here"
test: "set your test data path here"

nc: 11
names: ['CPU_FAN_NO_Screws', 'CPU_FAN_Screw_loose', 'CPU_FAN_Screws', 'CPU_fan', 'CPU_fan_port', 'CPU_fan_port_detached', 'Incorrect_Screws', 'Loose_Screws', 'No_Screws', 'Scratch', 'Screws']

roboflow:
workspace: yuelin-xin
project: motherboard-ptxx1
version: 13
license: CC BY 4.0
url: https://universe.roboflow.com/yuelin-xin/motherboard-ptxx1/dataset/13s
20 changes: 20 additions & 0 deletions inference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Import Libraries

from ultralytics import YOLO
import warnings
warnings.filterwarnings('ignore')

# Define testing image
image = "path to your testing image"
# Set the weight
model = YOLO("best.pt")
# Start prediction on the testing image
results = model.predict(source=image,conf=0.5, save=True) # save=True allow us to save the predicted image
# Retrieved training labels
names = model.names

# Loop to display predicted labels
for r in results:
for c in r.boxes.cls:
predicted_label = names[int(c)]
print(f" Predicted Labels are : {predicted_label}")
78 changes: 78 additions & 0 deletions inspection_webapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import PIL
import streamlit as st
from ultralytics import YOLO

# Give the path of the best.pt (best weights)
model_path = 'best.pt'

# Setting page layout
st.set_page_config(
page_title="MOTHERBOARD DEFECT INSPECTION WEBAPP SYSTEM)", # Setting page title
page_icon="image path to be the webapp icon", # Setting page icon
layout="wide", # Setting layout to wide
initial_sidebar_state="expanded", # Expanding sidebar by default

)

# Creating sidebar
with st.sidebar:
st.header("Image Config") # Adding header to sidebar
# Adding file uploader to sidebar for selecting images
source_img = st.file_uploader(
"Upload an image...", type=("jpg", "jpeg", "png", 'bmp', 'webp'))

# Model Options
confidence = float(st.slider(
"Select Model Confidence", 25, 100, 40)) / 100

# Creating main page heading
st.title("MOTHERBOARD DEFECT INSPECTION WEBAPP SYSTEM")
st.caption('Updload a photo by selecting :blue[Browse files]')
st.caption('Then click the :blue[Detect Objects] button and check the result.')
# Creating two columns on the main page
col1, col2 = st.columns(2)

# Adding image to the first column if image is uploaded
with col1:
if source_img:
# Opening the uploaded image
uploaded_image = PIL.Image.open(source_img)
image_width, image_height = (644, 644) #uploaded_image.size
# Adding the uploaded image to the page with a caption
st.image(source_img,
caption="Uploaded Image",
width=image_width
)

try:
model = YOLO(model_path)
except Exception as ex:
st.error(
f"Unable to load model. Check the specified path: {model_path}")
st.error(ex)

if st.sidebar.button('INSPECT'):
results = model.predict(uploaded_image,
conf=confidence,
line_width=3,
show_labels=True,
show_conf=False
)
boxes = results[0].boxes
results_plotted = results[0].plot(labels=True, line_width=4)[:, :, ::-1]
with col2:
st.image(results_plotted,
caption='Detected Image',
width=image_width
)
try:
names = model.names
st.write(f'Number of detected objects: {len(boxes)}')
predicted_label = list()
for r in results:
for c in r.boxes.cls:
predicted_label = names[int(c)]
st.text(predicted_label)

except Exception as ex:
st.write("No image is uploaded yet!")
10 changes: 10 additions & 0 deletions train_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from ultralytics import YOLO

# Load the model.
model = YOLO('yolov8n.pt')

model.train(
data='data.yaml',
imgsz=1000,
batch=4,
epochs=1000)
Binary file added webapp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 572e3d3

Please sign in to comment.