-
Notifications
You must be signed in to change notification settings - Fork 2
Transfer learning #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jackattack1415
wants to merge
95
commits into
dev
Choose a base branch
from
transfer_learning
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
95 commits
Select commit
Hold shift + click to select a range
9169f7d
Start of parsing of xml files for transfer learning
SamBlakeman 7ea9cfa
More parsing
SamBlakeman cb8ed6d
Deletion of xml file
SamBlakeman 8b34af2
updated checking of checkpoint fn
jackattack1415 6ec44bd
Dealing with empty xml files
SamBlakeman 688e3b0
More parsing of both the input and output data for transfer learning
SamBlakeman 9e1c1c4
benchmarking for performing object detection
jackattack1415 5456c9b
edited params and run_pipeline so they can run and be tested
jackattack1415 acb2bc3
Fixing issues with loading videos for the cvat dataset
SamBlakeman c0601a3
Working parsing of input and output data for transfer
SamBlakeman 1e45009
pulled dev
jackattack1415 fd32950
merged in sam's xml parsing branch
jackattack1415 6c0e245
refactoring
jackattack1415 d2d86ae
Merge branch 'object_detect_in_pipeline' of https://github.com/dssg/a…
jackattack1415 fbbe066
moved functions and other files from other github repo over
jackattack1415 cc2fa82
converted args.py to a .yml file
jackattack1415 e30fd46
refactoring changes
jackattack1415 fbff360
movement of files over from other github repo
jackattack1415 87c664c
madea few changes to sam's script
jackattack1415 dab9652
added function to load training params
jackattack1415 483f86c
converted everything away from args instead to the training_parameter…
jackattack1415 d0cb8c2
added lines to save a text file to be referenced
jackattack1415 6df30f2
fixed typo in epochs
jackattack1415 d247bc3
added missing package
jackattack1415 23028ee
formatted txt truth file so it fits requisite format for trainng
jackattack1415 e1b71a0
made changes to account for bug fixes
jackattack1415 b52a90a
legacy scripts kept in for the time being
jackattack1415 07a5bfa
changed to yolo_tf
jackattack1415 89461ea
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 260deb0
added paths so that sys is updated
jackattack1415 fc49252
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 9dae620
changed dir
jackattack1415 8c7ca7a
new transfer_learning pipeline script
jackattack1415 97aba35
fixed a quick bug with the configuration of the learning rate
jackattack1415 82d87f0
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 aecd924
fixed functions so they work with the transfer learning pipeline code
jackattack1415 5f29c33
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 ed8a895
fixed a bug with save_epoch
jackattack1415 9d14379
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 2866aed
batch size --> num batches
jackattack1415 78c0508
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 45b7da8
added evaluation on gpu instead of wrong fn
jackattack1415 58f364b
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 b53827b
reverted changes from last commit
jackattack1415 6aec004
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 0f7a52f
speed up map calculation
jackattack1415 4321336
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 3f54aab
fixed transfer_learning unifying code
jackattack1415 3840c20
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 615b0a0
changed selected labels idx selection because dict
jackattack1415 914c874
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 53bddb2
removed print statements
jackattack1415 e06f246
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 692d3fb
checking the map with print statements
jackattack1415 31203d8
hopefully remove nans
jackattack1415 81ae864
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 f5de8da
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 9213449
print statements added to debug
jackattack1415 8ffeaaa
fixed error with selected_labels_idx
jackattack1415 6cc8bc9
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 7c4b583
seeing if label idxs are actually strings
jackattack1415 8b50384
try to run with just 50 epochs
jackattack1415 d6fdd4e
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 0fc49ca
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 f4f3286
puts trained model in correct directory
jackattack1415 b3c3070
moved so i can run the code
jackattack1415 62ffdf5
changed so can try trained model
jackattack1415 77af1cf
changed path to labels
jackattack1415 97af1ee
break after 10 xmls
jackattack1415 2dccde7
trying out
jackattack1415 66464c0
print statement added to track downloading prog
jackattack1415 b40843f
changes committed
jackattack1415 0fa1dac
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 47cc6fb
correct break message now after 10 counts
jackattack1415 d0975d7
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 d4109b9
ok now break should actually work
jackattack1415 255efe8
added cvat annotations to the mix
jackattack1415 c03f217
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 f9ba589
got rid of print statements
jackattack1415 fb335c8
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 2d89d5b
see how transfer learning performed
jackattack1415 49284fd
merged from dev
jackattack1415 f53498c
delete example.py (not used)
jackattack1415 04016be
delete args.py (not used)
jackattack1415 7076e92
delete test.py (not used)
jackattack1415 ba4a9d8
added version to requirements
jackattack1415 8b6409d
merged dev
jackattack1415 d663fc3
deleted unused files
jackattack1415 3740c10
patching to address comments from recent pr
jackattack1415 61f855d
broke down tensorflow_training_utils into specific scripts
jackattack1415 0e56977
patching
jackattack1415 b64d5bb
Merge branch 'transfer_learning' of https://github.com/dssg/air_pollu…
jackattack1415 cc25d3a
merged from dev
jackattack1415 3ef194b
added blank lines to make pep8 compliant
jackattack1415 2d90db2
removed hard coding
jackattack1415 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| training: | ||
| num_batches : 10 | ||
| letterbox_resize : True # Whether to use letterbox resize, i.e., keep the original aspect ratio in the resized img. | ||
| total_epochs : 1000 | ||
| train_evaluation_step : 100 # Evaluate on the training batch after some steps. | ||
| val_evaluation_epoch : 2 # Evaluate on the validation dataset after some epochs. Set to None to evaluate all epoch. | ||
| save_epoch : 10 # Save the model after some epochs. | ||
| batch_norm_decay : 0.99 # decay in bn ops | ||
| weight_decay : 0.0005 # l2 weight decay | ||
| global_step : 0 # used when resuming training | ||
| warm_up_epoch : 3 # set to larger value if gradient explodes | ||
| num_threads : 10 # Number of threads for image processing used in tf.data pipeline. | ||
| prefetech_buffer : 5 # Prefetech_buffer used in tf.data pipeline. | ||
| trained_model_name : 'yolov3_traffic' | ||
|
|
||
| learning: | ||
| optimizer_name : 'momentum' # Chosen from [sgd, momentum, adam, rmsprop] | ||
| save_optimizer : True # Whether to save the optimizer parameters into the checkpoint file. | ||
| learning_rate_init : 0.0001 | ||
| lr_type : 'piecewise' # Chosen from [exponential, piecewise] | ||
| lr_decay_epoch : 5 # Epochs after which learning rate decays. Int or float. Used when chosen `exponential` lr_type. | ||
| lr_decay_factor : 0.96 # The learning rate decay factor. Used when chosen `exponential` lr_type. | ||
| lr_lower_bound : 0.000001 # The minimum learning rate. | ||
| pw_boundaries : [30, 50] # epoch based boundaries | ||
| pw_values : [0.0001, 0.00003, 0.00001] # FIRST VALUE MUST BE LEARNING_RATE_INIT | ||
|
|
||
| validation: | ||
| # nms | ||
| nms_threshold : 0.45 # iou threshold in nms operation | ||
| score_threshold : 0.01 # threshold of the prob of the classes in nms operation, i.e. score = pred_confs * pred_probs. | ||
| nms_topk : 150 # keep at most nms_topk outputs after nms | ||
|
|
||
| # mAP eval | ||
| eval_threshold : 0.5 # the iou threshold applied in mAP evaluation |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,4 @@ sqlalchemy | |
| pandas==0.24.2 | ||
| python-crontab>=2.3.8, <3.0 | ||
| seaborn>=0.9 | ||
| tqdm==4.33.0 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| from traffic_analysis.d00_utils.load_confs import load_paths, load_credentials, \ | ||
| load_parameters, load_training_parameters | ||
| from traffic_analysis.d04_modelling.transfer_learning.training_data_loader import TrainingDataLoader, TransferDataset | ||
| from traffic_analysis.d04_modelling.transfer_learning.train_tensorflow_model import transfer_learn | ||
|
|
||
| paths = load_paths() | ||
| creds = load_credentials() | ||
| params = load_parameters() | ||
| train_params = load_training_parameters() | ||
|
|
||
| training_data_loader = TrainingDataLoader(datasets=[TransferDataset.cvat, TransferDataset.detrac], | ||
| creds=creds, | ||
| paths=paths) | ||
|
|
||
| fraction_for_training = 0.8 | ||
| x_train, y_train, x_test, y_test = training_data_loader.get_train_and_test(fraction_for_training) | ||
|
|
||
|
|
||
| saved_text_files_dir = paths['temp_annotation'] | ||
| with open(saved_text_files_dir + 'train.txt', 'w') as f: | ||
| for item in y_train: | ||
| f.write("%s\n" % item) | ||
|
|
||
| with open(saved_text_files_dir + 'test.txt', 'w') as f: | ||
| for item in y_test: | ||
| f.write("%s\n" % item) | ||
|
|
||
| transfer_learn(paths=paths, | ||
| params=params, | ||
| train_params=train_params, | ||
| train_file='train.txt', | ||
| test_file='test.txt', | ||
| selected_labels=params['selected_labels']) | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
| import subprocess | ||
| from subprocess import Popen, PIPE | ||
|
|
||
| from traffic_analysis.d00_utils.data_loader_s3 import DataLoaderS3 | ||
|
|
||
|
|
||
| def upload_json_to_s3(paths: dict, | ||
| save_name: str, | ||
|
|
@@ -66,4 +68,48 @@ def get_names_of_folder_content_from_s3(bucket_name, prefix, s3_profile): | |
| end = Time.time() | ||
| elapsed_time = end-start | ||
|
|
||
| assert ((len(files) == 0) or (files[0] != '')), 'set your aws credentials' | ||
|
|
||
| return elapsed_time, files | ||
|
|
||
jackattack1415 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def get_s3_video_path_from_xml_name(xml_file_name, s3_creds, paths): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we already have a lot of the ingredients needed here in |
||
|
|
||
| # Supports old and new naming conventions | ||
| vals = xml_file_name.split('_') | ||
| data_loader_s3 = DataLoaderS3(s3_credentials=s3_creds, | ||
| bucket_name=paths['bucket_name']) | ||
|
|
||
| if (len(vals) >= 4): | ||
| date = vals[1] | ||
| file_names = [xml_file_name.split('_')[1:][0].replace('-', '') + '-' + | ||
| xml_file_name.split('_')[1:][1].replace('-', '')[:6] + '_' + | ||
| xml_file_name.split('_')[1:][2], | ||
| xml_file_name.split('_')[1:][0] + ' ' + | ||
| xml_file_name.split('_')[1:][1].replace('-', ':') + '_' + | ||
| xml_file_name.split('_')[1:][2]] | ||
| else: | ||
| date = vals[0] | ||
| file_names = [xml_file_name.split('_')[0].replace('-', '') + '-' + | ||
| xml_file_name.split('_')[1].replace('-', '')[:6] + '_' + | ||
| xml_file_name.split('_')[2], | ||
| xml_file_name.split('_')[0] + ' ' + | ||
| xml_file_name.split('_')[1].replace('-', ':') + '_' + | ||
| xml_file_name.split('_')[2]] | ||
| file_to_download = paths['s3_video'] + \ | ||
| date + '/' + \ | ||
| file_names[0] + '.mp4' | ||
|
|
||
| if(data_loader_s3.file_exists(file_to_download)): | ||
| return file_to_download | ||
|
|
||
| else: | ||
| file_to_download = paths['s3_video'] + \ | ||
| date + '/' + \ | ||
| file_names[1] + '.mp4' | ||
|
|
||
| if (data_loader_s3.file_exists(file_to_download)): | ||
| return file_to_download | ||
| else: | ||
| print('Could not download file: ' + xml_file_name) | ||
| return | ||
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems odd to me that we feed in these
txtfiles. Why don't we feed in data?