This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with open('/content/darknet/data/obj.data', 'w+') as obj_data: | |
| odata = f"""classes=1 | |
| train=/content/darknet/data/train.txt | |
| valid=/content/darknet/data/test.txt | |
| names=/content/darknet/data/obj.names | |
| backup=/content/drive/MyDrive/SuperMan_yolo_backup | |
| """ | |
| obj_data.write(odata) | |
| os.makedirs('/content/drive/MyDrive/SuperMan_yolo_backup', exist_ok=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NUM_CLASSES = 1 | |
| os.rename('/content/SuperMan/classes.txt', '/content/darknet/data/obj.names') | |
| os.rename('/content/SuperMan', '/content/darknet/data/obj/') | |
| data_path='/content/darknet/data/' | |
| with open(f'{data_path}train.txt', 'w+') as data_file: | |
| for image_file in os.listdir(f'{data_path}obj'): | |
| if image_file.endswith('.jpg'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %cd /content/ | |
| os.environ['KAGGLE_CONFIG_DIR'] = '/content/' | |
| !kaggle datasets download -d mralamdari/super-man-images-dataset | |
| !unzip \*.zip && rm *.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with open('/content/darknet/data/obj.data', 'w+') as obj_data: | |
| odata = f"""classes=1 | |
| train=/content/darknet/data/train.txt | |
| valid=/content/darknet/data/test.txt | |
| names=/content/darknet/data/obj.names | |
| backup=/content/drive/MyDrive/Batman_yolo_backup | |
| """ | |
| obj_data.write(odata) | |
| os.makedirs('/content/drive/MyDrive/Batman_yolo_backup', exist_ok=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NUM_CLASSES = 1 | |
| os.rename('/content/Batman/classes.txt', '/content/darknet/data/obj.names') | |
| os.rename('/content/Batman', '/content/darknet/data/obj/') | |
| data_path='/content/darknet/data/' | |
| with open(f'{data_path}train.txt', 'w+') as data_file: | |
| for image_file in os.listdir(f'{data_path}obj'): | |
| if image_file.endswith('.jpg'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %cd /content/ | |
| os.environ['KAGGLE_CONFIG_DIR'] = '/content/' | |
| !kaggle datasets download -d mralamdari/batman-images-dataset | |
| !unzip \*.zip && rm *.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %cd /content/darknet | |
| !./darknet detector test /content/darknet/data/obj.data /content/darknet/cfg/yolov3-custom.cfg /content/drive/MyDrive/yolov3_backup/yolov3-custom_last.weights /content/japan-2014616_960_720.jpg -thresh 0.3 -dont_show | |
| output_video = '/content/results.avi' | |
| !./darknet detector demo /content/darknet/data/obj.data /content/darknet/cfg/yolov3-custom.cfg /content/drive/MyDrive/yolov3_backup/yolov3-custom_last.weights /content/mixkit-busy-street-in-the-city-4000.mp4 -dont_show -i 0 -out_filename $output_video |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with open('/content/darknet/cfg/yolov3-custom.cfg', 'r+') as f: | |
| config_files = f.readlines() | |
| config_files[5] = '#'+config_files[5] # batch=64 | |
| config_files[6] = '#'+config_files[6] # subdivisions=16 | |
| config_files[2] = config_files[2][2:] # batch=1 | |
| config_files[3] = config_files[3][2:] # subdivisions=1 | |
| with open('/content/darknet/cfg/yolov3-custom.cfg', 'w+') as f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !./darknet detector train /content/darknet/data/obj.data /content/darknet/cfg/yolov3-custom.cfg /content/drive/MyDrive/yolo_backup/yolov3-custom_last.weights -dont_show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Download Pre-trained Weights | |
| !wget https://pjreddie.com/media/files/yolov3.weights |
NewerOlder