{"id":25828993,"url":"https://github.com/adaros92/genreml","last_synced_at":"2025-02-28T18:53:07.041Z","repository":{"id":55940579,"uuid":"300731299","full_name":"adaros92/genreml","owner":"adaros92","description":"Implements a neural network model for predicting genres from visual and audio features extracted from audio files.","archived":false,"fork":false,"pushed_at":"2020-12-05T16:04:02.000Z","size":110836,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-10T03:46:03.009Z","etag":null,"topics":["analytics","aws","feature-extraction","machine-learning","music","prediction","python","python3","webapp"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adaros92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-02T20:40:23.000Z","updated_at":"2020-12-28T23:44:10.000Z","dependencies_parsed_at":"2022-08-15T10:00:23.513Z","dependency_job_id":null,"html_url":"https://github.com/adaros92/genreml","commit_stats":null,"previous_names":["adaros92/cs467-project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaros92%2Fgenreml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaros92%2Fgenreml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaros92%2Fgenreml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adaros92%2Fgenreml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adaros92","download_url":"https://codeload.github.com/adaros92/genreml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241203810,"owners_count":19926858,"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":["analytics","aws","feature-extraction","machine-learning","music","prediction","python","python3","webapp"],"created_at":"2025-02-28T18:53:06.342Z","updated_at":"2025-02-28T18:53:07.033Z","avatar_url":"https://github.com/adaros92.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CS467-Project\nRepo for the CS467 capstone project\n\n### Contributing\n\n##### Git\nThe usual flow will be as follows.\n\n1. Clone the repo\n```\ngit clone git@github.com:adaros92/CS467-Project.git\n```\n2. Create new feature branch as feature/[name]\n```\ngit checkout main\ngit pull\ngit checkout -b feature/initial-structure\n```\n3. Add code/make changes in feature branch\n4. Commit to remote\n```\ngit add .\ngit commit -m \"Add initial structure to repository and contributing section to readme.md\"\ngit push origin feature/initial-structure\n```\n5. Submit a pull request at https://github.com/adaros92/CS467-Project/pulls from your feature branch to the main branch\n6. Resolve any comments locally and push a new revision to be reviewed\n7. Solve any merge conflicts and merge the pull request\n\nUseful git commands and references.\n\n* Display available branches `git branch`\n* Squashing commits into one for cleanliness https://gist.github.com/patik/b8a9dc5cd356f9f6f980\n* Merge branch \n```\ngit checkout main\ngit merge other-branch\n```\n* Gitflow documentation https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow\n\n##### Python Environment and Style\nIt's recommended to use the Pycharm IDE for making contributions. You can get it for free here: https://www.jetbrains.com/pycharm/. This will help you catch style and syntax issues early. \n\nWe will try to follow PEP 8 whenever possible as documented here: https://www.python.org/dev/peps/pep-0008/. If you use Pycharm then you won't need to read this because it will highlight issues for you :). \n\n### Installing Genreml\nInstall dependencies\nMac:\n```\nbrew install ffmpeg\n```\n\nUbuntu/Debian:\n```\nsudo apt-get install ffmpeg\n```\n\nTo install the package from Pypi as documented in https://pypi.org/project/genreml run:\n```\npip3 install genreml\nor\npip install genreml\n```\n\nTo install the package from the repo with Unix-based OS run the following in CS467-Project directory\n```\nbash install.sh\n```\n\nTest the installation by running the following in your terminal:\n```\ngenreml\n```\n\nIf the installation fails, ensure you have pip installed and that pip is correctly mapped (it may be pip3 on your system). If the genreml command\ndoesn't work then run the following as the entry point to the CLI.\n```\npython3 -m model\n```\n\nAlternatively, you can travel to the src/model and run the following as the main entry point without installing the app\n```\npython3 __main__.py\n```\n\n# Deploying the Webapp\nThe webapp is being hosted on an us-east-2 EC2 instance in AWS account 146066720211. The public IPv4 address is 3.135.235.199\nand the public IPv4 DNS is ec2-3-135-235-199.us-east-2.compute.amazonaws.com.\n\nTo deploy the webapp you will need to have SSH access to this instance. The key being used is available in \nhttps://drive.google.com/file/d/1fc8yxqEZlNGF2s5lqqqSsr_oKaBHHcmA/view?usp=sharing to OSU students. To connect to the\ninstance you can run ssh -i \"MyKey4.pem\" ubuntu@ec2-3-135-235-199.us-east-2.compute.amazonaws.com from the same directory\nas where MyKey4.pem is stored on your machine or provide a path to MyKey4.pem after -i argument like \nssh -i \"/Users/adamsrosales/Downloads/MyKey4.pem\" ubuntu@ec2-3-135-235-199.us-east-2.compute.amazonaws.com.\n\nThere is a shell script in this repo (deploy_webapp.sh) that copies the contents of the webapp to the right location on the\nEC2 machine. You will need to provide the location of the private key on your machine when running it like so:\nbash deploy_webapp.sh /Users/adamsrosales/Downloads/MyKey4.pem.\n\nThe deployment is configured like so.\n\nIn /etc/nginx/sites-enabled/ there's a file called app with the following configuration which is the nginx\nconfiguration for hosting the site.\n\n```\nserver {\n    listen 80;\n    server_name 3.135.235.199;\n\n    location / {\n        proxy_pass http://127.0.0.1:8000;\n        proxy_set_header Host $host;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    }\n} \n```\n\nIf you make any changes run deploy_webapp.sh to copy the contents of the webapp to the server and run:\n\n```\nsudo nginx -s reload\nsudo supervisorctl reload\n```\n\nTo contents of the webapp are found in /home/ubuntu/webapp and they're being run by gunicorn. To\nsee all the gunicorn processes run\n\n```\nps ax|grep gunicorn\n```\n\nTo kill the gunicorn processes run\n\n```\nsudo pkill gunicorn\n```\n\nTo start the gunicorn process run this from the /home/ubuntu/webapp directory. This will start the site hosting.\n```\ngunicorn -w 2 frontend:app\n```\n\nThe site can be accessed by traveling to the public EC2 DNS name: \n```\nhttp://ec2-3-12-132-1.us-east-2.compute.amazonaws.com/\n```\n\n# Running the CLI\n\n**The youtube functionality is not currently working due to youtube-dl takedown**\n\nDownloading audio files to your machine (**This is no longer working due to youtube-dl takedown**)\n```\ngenreml download -s \"Black Dog\" -a \"Led Zeppelin\"\n```\n\nYou can do the same without installing the app by traveling to the model package and running\n```\npython3 __main__.py download -s \"Black Dog\" -a \"Led Zeppelin\"\n```\n\nProcessing audio files stored in some drive on your machine\n```\ngenreml process -fp \"/Users/adamsrosales/Documents/audio-clips/\"\n```\n\nYou can do the same without installing the app by traveling to the model package and running\n```\npython3 __main__.py process -fp \"/Users/adamsrosales/Documents/audio-clips/\"\n```\n\nThe same can be run with a single file\n```\ngenreml process -fp \"/Users/adamsrosales/Documents/audio-clips/Yummy_Justin Bieber_clip.wav\"\n```\n\nTo ignore certain features from the feature extraction process\n```\n# Ignore spectrogram generation\ngenreml process -fp \"/Users/adamsrosales/Documents/audio-clips/fma_small/000\" -e spectrogram\n```\n\nTo change audio file type\n```\ngenreml process -fp \"/Users/adamsrosales/Documents/audio-clips/fma_small/000\" -af mp3\n```\n\nTo change export color images and change image size to X in wide by Y in high\n```\ngenreml process -fp \"/Users/adamsrosales/Documents/audio-clips/fma_small/000\" -cmap None -fw 15.0 -fh 5.0\n```\n\nTo predict genres from an audio file\n```\ngenreml classify -fp \"/Users/adamsrosales/Documents/audio-clips/fma_small/000/000002.mp3\"\n```\n\nTo predict genres from a youtube URL\n```\ngenreml classify -yu \"https://www.youtube.com/watch?v=Ui-_IUylvoA\"\n```\n\nTo predict genres from a compatible h5 model\n```\ngenreml classify -mp \"/Users/adamsrosales/Downloads/FMA_model.h5\" -yu \"https://www.youtube.com/watch?v=Ui-_IUylvoA\"\n```\n\n# Using genreml as a Package in Python\n\nYou can import genreml after a successful installation like any Python package\n```\nimport genreml\n```\n\nSee genreml/model/__main__ for the hooks into the genreml functionality that the CLI has. Some examples below.\n\nRun feature extraction on sample FMA MP3s packaged with application.\n```\nfrom genreml.model.processing import audio\n\naudio_files = audio.AudioFiles()\naudio_files.extract_sample_fma_features()\n```\n\nRun feature extraction on already loaded data.\n```\nfrom genreml.model.processing import audio\n\naudio_files = audio.AudioFiles()\naudio_files.extract_sample_fma_features()\n\n# Get the raw audio data from already loaded files\naudio_signal_data = []\nsample_rate_data = []\nfor _, audio_obj in audio_files_processor.items():\n    audio_signal_data.append(audio_obj.audio_signal)\n    sample_rate_data.append(audio_obj.sample_rate)\n\n# Use that raw data for feature extraction with AudioData class\naudio_data_processor = AudioData(audio_signal_data, sample_rate_data)\naudio_data_processor.extract_features()\n```\n\naudio.AudioFiles() and AudioData() just create a dictionary of individual file paths to audio data. \nYou can extract the data from the collection as you would with any dictionary.\n```\naudio_signals = []\nsample_rates = []\nfor audio_key, object in audio_files.items():\n    audio_signals.append(object.audio_rate)\n    sample_rates.append(object.sample_rates)\n```\n\nYou can also get all of the visual and non-visual features extracted from the audio collection itself.\n```\nmy_features = audio_files.features\nmy_visual_features = audio_files.visual_features\n```\n\nConvert features to Pandas data frame\n```\ndf = audio_files.to_df()\n```\n\nRun feature extraction on a directory or filepath of your choice\n```\naudio_files.extract_features(\"[YOUR_FILE_PATH]\")\n```\n\nRun feature extraction on a directory or filepath of your choice but export results to a destination filepath\n```\naudio_files.extract_features(\"[YOUR_FILE_PATH]\", destination_filepath=\"[YOUR_DESTINATION_PATH]\")\n```\n\nChange color of images generated from feature extraction\n```\naudio_files.extract_features(\"[YOUR_FILE_PATH]\", destination_filepath=\"[YOUR_DESTINATION_PATH]\", cmap=None)\n```\n\nChange size of images generated to 15 by 5 inches\n```\naudio_files.extract_features(\n    \"[YOUR_FILE_PATH]\", destination_filepath=\"[YOUR_DESTINATION_PATH]\",\n    figure_width=15, figure_height=5\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaros92%2Fgenreml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadaros92%2Fgenreml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaros92%2Fgenreml/lists"}