SteveMacenski / jetson_nano_detection_and_tracking

Jetson Nano ML install scripts, automated optimization of robotics detection models, and filter-based tracking of detections
GNU Lesser General Public License v2.1
226 stars 66 forks source link

Retrain mobilenet v2 SSD #9

Closed Tdoe4321 closed 5 years ago

Tdoe4321 commented 5 years ago

I also have a question for you. You mention that you were able to re-train a network and use it with your scripts here to change it into the tensorRT format and use it for inference. I was wondering what that process looks like. That's basically what I'm trying to do and I can't seem to figure out how I would do that with your method here.

Thanks

SteveMacenski commented 5 years ago

The method here is just reading a tensorRT optimized graph for inferencing. Any model from (nearly any) DL library (pytorch, tensorflow, etc) can be converted using the functionality Nvidia or that client library uses.

I think the question you're really asking is how to retrain models, once you've retrained the model, its no different than just downloading the weights from another project. For the answer to that question, I'd point you to resources of the client DL library of your choice, this is probably not the best place for that discussion.

A canonical example can be seen here: https://github.com/datitran/raccoon_dataset

SteveMacenski commented 5 years ago

To give you some more context:

trt_graph = trt.create_inference_graph(
    input_graph_def=frozen_graph,
    outputs=output_names,
    max_batch_size=1,
    max_workspace_size_bytes=1 << 25,
    precision_mode='FP16',
    minimum_segment_size=50
)

Is really the only line that matters here. Once you've retrained your model, this function is the "key" to the download/optimize script. You just need to change the first 2 parameterizations. For the Nano, leave the batch size, ma workspace, precision, and segment the same.

Tdoe4321 commented 5 years ago

I hate to keep asking silly questions, but I'm about three days into any sort of Neural Network exposure and I'm trying to keep up.

The last thing I have a question on is where/how I setup the outputs for my trained network version. I believe I understand how to go about re-training a network and getting a frozen graph out from it, but I don't think I see what I'm supposed to link that output_names to. If I understand correctly, I need to link it to a list of my classes, but I'm not sure what that looks like. I can only find the: output_names = [BOXES_NAME, CLASSES_NAME, SCORES_NAME, NUM_DETECTIONS_NAME] But I don't know if I'm supposed to change anything for that. I know that tensorflow outputs the bounding box data in the above format, but I'm just a little confused.

Thanks again, you've been super helpful and I'm working on some pull requests.

SteveMacenski commented 5 years ago

As long as you're still using the same network, those wont change if you dont mess with the config files outside of your training needs