<jupyter_start><jupyter_text>Preparing the Data<jupyter_code>import random
from sklearn import preprocessing
import pandas as pd
groundtruth=pd.read_csv('/content/sample_data/groundtruth.csv')
width=640
height=480
groundtruth['x']=0
groundtruth['y']=0
groundtruth['w']=0
groundtruth['h']=0
original=pd.read_csv('/content/sample_data/groundtruth.csv')
#print(groundtruth)
#groundtruth['class']= random.randint(1,4)
groundtruth[['xmin', 'xmax','ymin','ymax','x','y','w','h']] = groundtruth[['xmin', 'xmax','ymin','ymax','x','y','w','h']].astype(float)
print(groundtruth.dtypes)

%cd /content/yolov5/data/labels/train
for x in groundtruth.iterrows():
  #print( x[1][5])
  x[1][5] = (x[1][1]) / width
  x[1][6]= (x[1][2]) / height
  x[1][7]= (x[1][3] - x[1][1]) / width
  x[1][8]= (x[1][4]- x[1][2]) / height
  classn=random.randint(0,3)
  filename=int(x[1][0])
  #print(r)
  classn=int(classn)
  pd.DataFrame([classn,x[1][5],x[1][6],x[1][7],x[1][8]]).to_csv(str(filename)+".txt",float_format='%g', header=False, index=False,line_terminator=' ')
import random
from sklearn import preprocessing
import pandas as pd
groundtruth=pd.read_excel('/content/sample_data/groundtruth1.xlsx')
width=640
height=480
groundtruth['x']=0
groundtruth['y']=0
groundtruth['w']=0
groundtruth['h']=0
#original=pd.read_csv('/content/sample_data/groundtruth1.csv')
#print(groundtruth)
#groundtruth['class']= random.randint(1,4)
groundtruth[['xmin', 'xmax','ymin','ymax','x','y','w','h']] = groundtruth[['xmin', 'xmax','ymin','ymax','x','y','w','h']].astype(float)
print(groundtruth.dtypes)
%cd /content/yolov5/data/labels/val
for x in groundtruth.iterrows():
  #print( x[1][5])
  x[1][5] = (x[1][1]) / width
  x[1][6]= (x[1][2]) / height
  x[1][7]= (x[1][3] - x[1][1]) / width
  x[1][8]= (x[1][4]- x[1][2]) / height
  classn=random.randint(0,3)
  filename=int(x[1][0])
  #print(r)
  classn=int(classn)
  pd.DataFrame([classn,x[1][5],x[1][6],x[1][7],x[1][8]]).to_csv(str(filename)+".txt",float_format='%g', header=False, index=False,line_terminator=' ')

import zipfile
with zipfile.ZipFile("/content/sample_data/train1.zip","r") as zip_ref:
    zip_ref.extractall("/content/yolov5/data/images")

import zipfile
with zipfile.ZipFile("/content/sample_data/val.zip","r") as zip_ref:
    zip_ref.extractall("/content/yolov5/data/images")
%cd /content/
!git clone https://github.com/DLR-RM/BlenderProc.git

# Download some required libraries
import os
 
!apt install libtcmalloc-minimal4

os.environ["LD_PRELOAD"] = "/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4.3.0"

!apt install libboost-all-dev
!apt install libgl1-mesa-dev 
%cd /content/yolov5
!python train.py --img 640 --batch 20 --epochs 10 --data /content/sample_data/ulcer.yaml --weights yolov5s.pt --name yolov5s_results  --cache
!python detect.py --source /content/yolov5/data/images/val/101609.jpg --weights /content/yolov5/runs/train/yolov5s_results/weights/best.pt
import glob
from IPython.display import Image, display

for imageName in glob.glob('/content/yolov5/runs/detect/exp/101609.jpg'): #assuming JPG
    display(Image(filename=imageName))
    print("\n")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21622484829128075, 'fraction_numerical': 0.04279782816991377, 'mean_word_length': 6.352112676056338, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '275126', 'license': 'Unlicense', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1273, 'n_words': 186, 'path': 'yolov5 (2).ipynb', 'repo_name': '240897/ResearchProjectT2', 'size': '3131'}