{"id":13737145,"url":"https://github.com/arnabdeypolimi/Image-classification-PyTorch-MLflow","last_synced_at":"2025-05-08T13:33:04.614Z","repository":{"id":67838825,"uuid":"255173254","full_name":"arnabdeypolimi/Image-classification-PyTorch-MLflow","owner":"arnabdeypolimi","description":"Image classification using Transfer learning technique. Updated and added mlflow with PyTorch fine-tune tutorial","archived":false,"fork":false,"pushed_at":"2020-08-10T15:06:17.000Z","size":150,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-03T03:08:01.559Z","etag":null,"topics":["densenet","fine-tuning","image-classification","imageclassification","inceptionv3","mlflow","mlflow-pytorch","python","pytorch","resnet","squeezenet","torchvision","transfer-learning","vgg16"],"latest_commit_sha":null,"homepage":"https://pytorch.org/tutorials/beginner/finetuning_torchvision_models_tutorial.html","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnabdeypolimi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-12T21:27:34.000Z","updated_at":"2024-08-03T03:08:02.100Z","dependencies_parsed_at":"2023-05-03T01:02:15.915Z","dependency_job_id":null,"html_url":"https://github.com/arnabdeypolimi/Image-classification-PyTorch-MLflow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabdeypolimi%2FImage-classification-PyTorch-MLflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabdeypolimi%2FImage-classification-PyTorch-MLflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabdeypolimi%2FImage-classification-PyTorch-MLflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnabdeypolimi%2FImage-classification-PyTorch-MLflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnabdeypolimi","download_url":"https://codeload.github.com/arnabdeypolimi/Image-classification-PyTorch-MLflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224737431,"owners_count":17361345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["densenet","fine-tuning","image-classification","imageclassification","inceptionv3","mlflow","mlflow-pytorch","python","pytorch","resnet","squeezenet","torchvision","transfer-learning","vgg16"],"created_at":"2024-08-03T03:01:36.085Z","updated_at":"2025-05-08T13:33:04.599Z","avatar_url":"https://github.com/arnabdeypolimi.png","language":"Jupyter Notebook","readme":"# Image-classification-PyTorch-MLflow\n\nThe repository contain code for image classification using `PyTorch`. I have also used `MLflow` to track the experiments. \nThis code has added features like `MLflow`, Confustion matrix generation, prediction and model saving.\n\nThis repository only contain the code for training the models. Data pre-processing and dataset creation code is not present in this repository but can be added in future on request. \n\nDatasets can be trained with `VGG, SqueezeNet, DenseNet, ResNet, AlexNet, Inception` using this repository. \n\n## Dataset folder structure should be:\n```\nroot\n└── dataset\n        ├── Train\n        │   ├── Class 1\n        │   │   ├── Sample 1\n        │   │   ├── .........\n        │   │   └── Sample N\n        │   ├── ........\n        │   └── Class N\n        │       ├── Sample 1\n        │       ├── .........\n        │       └── Sample N\n        └── Val\n            ├── Class 1\n            │   ├── Sample 1\n            │   ├── .........\n            │   └── Sample N\n            ├── ........\n            └── Class N\n                ├── Sample 1\n                ├── .........\n                └── Sample N\n```\n## Config File\nIt is a json file where we will add all the parameters and paths required for training.\nmodel_name input is the name of the model you wish to use and must be selected from this list:[resnet, alexnet, vgg, squeezenet, densenet, inception]\nnum_classes is the number of classes in the dataset, batch_size is the batch size used for training and may be adjusted according to the capability of your machine, num_epochs is the number of training epochs we want to run, and feature_extract is a boolean that defines if we are finetuning or feature extracting. If feature_extract = False, the model is finetuned and all model parameters are updated. If feature_extract = True, only the last layer parameters are updated, the others remain fixed.\n```\n{\n  \"model_name\":\"\u003csqueezenet/resnet/vgg16/densenet/alexnet/inception\u003e\", \n  \"num_classes\": \"\u003cnumber of classes\u003e\",\n  \"batch_size\": \"32\",\n  \"num_epochs\": \"\u003cnumber of epoches\u003e\",\n  \"feature_extract\": \"False\",\n  \"pre_trained\": \"True\",\n  \"save_model\": \"\u003cpath to save model\u003e\",\n  \"save_confusion_mat\": \"/exp/data/densenet_17_mat.csv\",\n  \"data_dir\":\"\u003cpath of the dataset\u003e\",\n  \"classes\": [\u003clist of class names\u003e]\n}\n\n```\n\n## Training steps \n\n- edit the `config_files/training.json` \n- run `python main.py --config training`\n- after finshing the training it will create confusion matrix \n- the notebook will also save trained model with `pytorch` and `mlflow`  \n    \n## MLflow \n\n`MLflow` helps in tracking experiments, packaging code into reproducible runs, and sharing and deploying models. You can \nfind more information about `MLflow` [Here](https://mlflow.org/).\nI have used `MLflow` to track my experiments and save parameters used for a particular training. We tracked 7 parameters in\nthis case which can be seen later. \n\n- Install MLflow from PyPI via ```pip install mlflow```\n- The MLflow Tracking UI will show runs logged in `./mlruns` at [http://localhost:5000](http://localhost:5000). Start it with:\n`mlflow ui`\n\n## Run as Docker Container \n\n- `sudo docker build -t classification:0.1 .`\n- `sudo docker run -it --rm -p 5000:5000 -v \u003cdataset path\u003e:/code/data/ classification:0.1`\n- `cd code`\n- `python main.py --config training`\n- `mlflow server --host=0.0.0.0`\n- `http://localhost:5000/`\n","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnabdeypolimi%2FImage-classification-PyTorch-MLflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnabdeypolimi%2FImage-classification-PyTorch-MLflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnabdeypolimi%2FImage-classification-PyTorch-MLflow/lists"}