{"id":18603966,"url":"https://github.com/farzeennimran/moon-phases-prediction-using-ai","last_synced_at":"2026-04-07T22:32:18.800Z","repository":{"id":248670374,"uuid":"822591627","full_name":"farzeennimran/Moon-Phases-Prediction-Using-AI","owner":"farzeennimran","description":"Deep learning model that predicts the phase of the moon 🌒🌓🌔🌕🌖🌗🌘","archived":false,"fork":false,"pushed_at":"2025-03-25T12:39:53.000Z","size":18214,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-16T18:44:10.246Z","etag":null,"topics":["artificial-intelligence","cnn","cv2-library","data-science","data-visualization","deep-learning","keras","matplotlib","numpy","opencv","predictive-modeling","python","tensorflow"],"latest_commit_sha":null,"homepage":"","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/farzeennimran.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":"2024-07-01T12:43:04.000Z","updated_at":"2025-03-25T12:39:57.000Z","dependencies_parsed_at":"2024-12-27T01:02:02.275Z","dependency_job_id":null,"html_url":"https://github.com/farzeennimran/Moon-Phases-Prediction-Using-AI","commit_stats":null,"previous_names":["farzeennimran/moon-phases-prediction-using-ai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/farzeennimran/Moon-Phases-Prediction-Using-AI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FMoon-Phases-Prediction-Using-AI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FMoon-Phases-Prediction-Using-AI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FMoon-Phases-Prediction-Using-AI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FMoon-Phases-Prediction-Using-AI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farzeennimran","download_url":"https://codeload.github.com/farzeennimran/Moon-Phases-Prediction-Using-AI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FMoon-Phases-Prediction-Using-AI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31532291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["artificial-intelligence","cnn","cv2-library","data-science","data-visualization","deep-learning","keras","matplotlib","numpy","opencv","predictive-modeling","python","tensorflow"],"created_at":"2024-11-07T02:16:06.199Z","updated_at":"2026-04-07T22:32:18.780Z","avatar_url":"https://github.com/farzeennimran.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Moon Phase Prediction\n\nThis repository contains code for a deep learning model that predicts the phase of the moon from an input image. The model is built using Convolutional Neural Networks (CNNs) and classifies images into one of the eight moon phases.\n\n## Table of Contents\n- [Overview](#overview)\n- [Dataset](#dataset)\n- [Model Architecture](#model-architecture)\n- [Training](#training)\n- [Evaluation](#evaluation)\n- [Making Predictions](#Making-Predictions)\n- [Results](#results)\n\n## Overview\nThe goal of this project is to accurately classify images of the moon into one of eight phases:\n1. New Moon\n2. Waxing Crescent\n3. First Quarter\n4. Waxing Gibbous\n5. Full Moon\n6. Waning Gibbous\n7. Last Quarter\n8. Waning Crescent\n\n## Dataset\nInitially the datatset was taken from kaggle that consisted of images of the moon. I labeled the images with their respective phases, such that, images are organized in subdirectories named after the phases. Ensure that the dataset is unzipped and placed in the correct directory structure.\n\n## Model Architecture\nThe model is a Convolutional Neural Network (CNN) with the following architecture:\n- Convolutional layers with ReLU activation\n- MaxPooling layers\n- Flatten layer\n- Dense layers with ReLU activation\n- Dropout layer\n- Output layer with softmax activation\n\n```python\nmodel = Sequential([\n    Conv2D(32, (3, 3), activation='relu', input_shape=(IMG_SIZE, IMG_SIZE, 3)),\n    MaxPooling2D(2, 2),\n    Conv2D(64, (3, 3), activation='relu'),\n    MaxPooling2D(2, 2),\n    Flatten(),\n    Dense(128, activation='relu'),\n    Dropout(0.5),\n    Dense(len(CATEGORIES), activation='softmax')\n])\n\nmodel.summary()\n```\n![model](https://github.com/user-attachments/assets/c2e99836-7930-4790-a0cf-5ad0943010b5)\n\n\n## Training\nThe images are loaded, resized, and normalized. The labels are converted to categorical format. The dataset is split into training and testing sets. The model is then compiled and trained.\n\n```python\nmodel.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\nhistory = model.fit(X_train, y_train, epochs=20, validation_data=(X_test, y_test))\n```\n![epochs](https://github.com/user-attachments/assets/b98d36e6-4fda-45fe-b7bb-b33a40b57a09)\n\n\n## Evaluation\nThe model's performance is evaluated on the test set.\n\n```python\nloss, accuracy = model.evaluate(X_test, y_test)\nprint(\"Test Accuracy:\", accuracy)\n```\n\n![acc](https://github.com/user-attachments/assets/207b1e21-a604-448d-bf52-a180e50fee89)\n\n\n## Making Predictions\nYou can use the trained model to predict the moon phase of new images.\n\n```python\ndef predict_moon_phase(model, img_path):\n    img = cv2.imread(img_path)\n    img_resized = cv2.resize(img, (IMG_SIZE, IMG_SIZE))\n    img_normalized = img_resized / 255.0\n    img_reshaped = np.reshape(img_normalized, (1, IMG_SIZE, IMG_SIZE, 3))\n    prediction = model.predict(img_reshaped)\n    return CATEGORIES[np.argmax(prediction)]\n```\n\nTesting model on different images\n\n```python\nimg_path = 'test.jpg'\npredicted_phase = predict_moon_phase(model, img_path)\nprint(\"The predicted moon phase is:\", predicted_phase)\n```\n![test_result](https://github.com/user-attachments/assets/48208ee7-c213-4d84-8895-6b5b98c5f88f)\n\n```python\nimg_path = 'test1.jpg'\npredicted_phase = predict_moon_phase(model, img_path)\nprint(\"The predicted moon phase is:\", predicted_phase)\n```\n![test1_result](https://github.com/user-attachments/assets/bd716618-eb62-4a5e-89b7-e26320af27a7)\n\n```python\nimg_path = 'test2.jpg'\npredicted_phase = predict_moon_phase(model, img_path)\nprint(\"The predicted moon phase is:\", predicted_phase)\n```\n\n![test2_result](https://github.com/user-attachments/assets/4609a8be-85cb-42cd-8a38-8edc0af28154)\n\n## Results\nThe training and validation loss and accuracy are plotted to visualize the model's performance over epochs.\n\n![accuracy](https://github.com/user-attachments/assets/3fbab1fe-3327-48e7-b9ca-501172fc552b)\n\n\n![loss](https://github.com/user-attachments/assets/7a89291e-d8fd-458a-942e-d12f33c46214)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarzeennimran%2Fmoon-phases-prediction-using-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarzeennimran%2Fmoon-phases-prediction-using-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarzeennimran%2Fmoon-phases-prediction-using-ai/lists"}