Spaces:
Sleeping
Sleeping
Commit ·
25152cf
1
Parent(s): b4dc0b3
Add application file and upload model
Browse filesFiles changed (27)
- app.pyAdded+71
- model/F1_curve.pngAdded
- model/PR_curve.pngAdded
- model/P_curve.pngAdded
- model/R_curve.pngAdded
- model/args.yamlAdded+105
- model/config.jsonAdded+1
- model/confusion_matrix.pngAdded
- model/confusion_matrix_normalized.pngAdded
- model/labels.jpgAdded
- model/labels_correlogram.jpgAdded
- model/results.csvAdded
- model/results.pngAdded
- model/train_batch0.jpgAdded
- model/train_batch1.jpgAdded
- model/train_batch1323370.jpgAdded
- model/train_batch1323371.jpgAdded
- model/train_batch1323372.jpgAdded
- model/train_batch2.jpgAdded
- model/val_batch0_labels.jpgAdded
- model/val_batch0_pred.jpgAdded
- model/val_batch1_labels.jpgAdded
- model/val_batch1_pred.jpgAdded
- model/val_batch2_labels.jpgAdded
- model/val_batch2_pred.jpgAdded
- model/weights/best.ptAdded+3
- model/weights/last.ptAdded+3
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071# Import required librariesimport PIL
import streamlit as stfrom ultralytics import YOLO
# Replace the relative path to your weight filemodel_path = 'model/weights/best.pt'
# Setting page layoutst.set_page_config( page_title="Tribe-Level Bee Object Detection", # Setting page title page_icon="🐝", # Setting page icon layout="wide", # Setting layout to wide initial_sidebar_state="expanded", # Expanding sidebar by default )
# Creating sidebarwith st.sidebar: st.header("Configuration") # 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 headingst.title("Object Detection")st.caption('Upload a photo containing a bee, and we\'ll find it for you and tell you which tribe it belongs to')st.caption('Use the slider to choose the confidence threshold, then hit the :blue[Detect Objects] button for your results!')# Creating two columns on the main pagecol1, col2 = st.columns(2)
# Adding image to the first column if image is uploadedwith col1: if source_img: # Opening the uploaded image uploaded_image = PIL.Image.open(source_img) # Adding the uploaded image to the page with a caption st.image(source_img, caption="Uploaded Image", use_column_width=True )
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('Detect Objects'): res = model.predict(uploaded_image, conf=confidence ) boxes = res[0].boxes res_plotted = res[0].plot()[:, :, ::-1] with col2: st.image(res_plotted, caption='Detected Image', use_column_width=True ) try: with st.expander("Detection Results"): for box in boxes: st.write(box.xywh) except Exception as ex: st.write("No image is uploaded yet!")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105task: detectmode: trainmodel: yolov8n.yamldata: config.yamlepochs: 600time: nullpatience: 100batch: 16imgsz: 640save: truesave_period: -1cache: falsedevice: nullworkers: 8project: nullname: train5exist_ok: falsepretrained: trueoptimizer: autoverbose: trueseed: 0deterministic: truesingle_cls: falserect: falsecos_lr: falseclose_mosaic: 10resume: falseamp: truefraction: 1.0profile: falsefreeze: nullmulti_scale: falseoverlap_mask: truemask_ratio: 4dropout: 0.0val: truesplit: valsave_json: falsesave_hybrid: falseconf: nulliou: 0.7max_det: 300half: falsednn: falseplots: truesource: nullvid_stride: 1stream_buffer: falsevisualize: falseaugment: falseagnostic_nms: falseclasses: nullretina_masks: falseembed: nullshow: falsesave_frames: falsesave_txt: falsesave_conf: falsesave_crop: falseshow_labels: trueshow_conf: trueshow_boxes: trueline_width: nullformat: torchscriptkeras: falseoptimize: falseint8: falsedynamic: falsesimplify: falseopset: nullworkspace: 4nms: falselr0: 0.01lrf: 0.01momentum: 0.937weight_decay: 0.0005warmup_epochs: 3.0warmup_momentum: 0.8warmup_bias_lr: 0.1box: 7.5cls: 0.5dfl: 1.5pose: 12.0kobj: 1.0label_smoothing: 0.0nbs: 64hsv_h: 0.015hsv_s: 0.7hsv_v: 0.4degrees: 0.0translate: 0.1scale: 0.5shear: 0.0perspective: 0.0flipud: 0.0fliplr: 0.5mosaic: 1.0mixup: 0.0copy_paste: 0.0auto_augment: randaugmenterasing: 0.4crop_fraction: 1.0cfg: nulltracker: botsort.yamlsave_dir: runs/detect/train51{"input_size": 640, "task": "object-detection", "ultralyticsplus_version": "0.1.0", "ultralytics_version": "8.0.239", "model_type": "v8", "score_map50": 0.67246}123version https://git-lfs.github.com/spec/v1oid sha256:265873a747ab082fb4a85956c6ad6c54308aa4557c970c9af153a05aa116ae75size 6287193123version https://git-lfs.github.com/spec/v1oid sha256:3974c4025ccf66fde8b7d4734a38c5158e271444dd69b9b8118d0552ba8f6a35size 6298009app.pyAdded+71
model/F1_curve.pngAdded

model/PR_curve.pngAdded

model/P_curve.pngAdded

model/R_curve.pngAdded

model/args.yamlAdded+105
model/config.jsonAdded+1
model/confusion_matrix.pngAdded

model/confusion_matrix_normalized.pngAdded

model/labels.jpgAdded

model/labels_correlogram.jpgAdded

model/results.csvAdded
model/results.pngAdded

model/train_batch0.jpgAdded

model/train_batch1.jpgAdded

model/train_batch1323370.jpgAdded

model/train_batch1323371.jpgAdded

model/train_batch1323372.jpgAdded

model/train_batch2.jpgAdded

model/val_batch0_labels.jpgAdded

model/val_batch0_pred.jpgAdded

model/val_batch1_labels.jpgAdded

model/val_batch1_pred.jpgAdded

model/val_batch2_labels.jpgAdded

model/val_batch2_pred.jpgAdded

model/weights/best.ptAdded+3
model/weights/last.ptAdded+3