Code Monkey home page Code Monkey logo

ritwik12 / celestial-bodies-detection Goto Github PK

View Code? Open in Web Editor NEW
84.0 8.0 56.0 219.7 MB

TensorFlow Image Classifier that can be used to classify whether an image is of a Planet (Earth, Mercury, Mars, etc), Galaxy (Spiral, Elliptical, Irregular), Satellites, Comets, Etc.

Home Page: https://celestial-bodies-detection.herokuapp.com

License: GNU General Public License v3.0

Python 79.20% Starlark 0.51% CSS 5.32% JavaScript 1.46% HTML 13.45% Procfile 0.06%
tensorflow artificial-intelligence machine-learning convolutional-neural-networks python linux deep-learning

celestial-bodies-detection's Introduction

Visit Site to use the model.

Setup

Tensorflow

Create a virtual environment (recommended)

Python virtual environments are used to isolate package installation from the system.

Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:

virtualenv --system-site-packages -p python3 ./venv

Activate the virtual environment using a shell-specific command:

source ./venv/bin/activate # sh, bash, ksh, or zsh

If using conda, you can run conda create -n tensorflow python=3.7 source activate tensorflow

Install Requirements

Move to the image_training directory: cd /hub/examples/image_retraining

pip install -r requirements.txt

OR

Install Tensorflow

pip install tensorflow==1.14

Install wikipedia

pip install wikipedia

Install PyYAML

pip install PyYAML

Inception

Downloaded automatically while training

Using Webapp

Simple visit site or local deploy webapp with the help of instructions mentioned below:

Run

python run.py

Details

  • The webapp is made using Flask, the static files (css, js, img), templates and views.py are in the /app/ directory.
  • There are four endpoints:
    • / - Home page. Here, the user will select image to upload or enter the url.
    • /result - Results after processing. Shows the image, labels, wiki.
    • /redirectToGoogle - Redirects to google image search.
    • /about - About the project.

Screenshot 2021-07-02 at 3 54 51 PM

Screenshot 2021-07-02 at 3 55 13 PM

Using Model

Classified Neptune Image and percentage of Accuracy

output1

Classified Jupiter Image and percentage of Matched Accuracy

output3

Shows the percentage of every class

output2

Fetched information from Internet

output4

Reverse Search of Classified Image

output5

Accuracy of matching of Spiral Galaxy

output6

Fetched information from Internet of the Classified Class

output7

Train model

python retrain.py --bottleneck_dir=bottlenecks --how_many_training_steps=500 --model_dir=inception --summaries_dir=training_summaries/basic --output_graph=retrained_graph.pb --output_labels=retrained_labels.txt --image_dir=./training_data

Evaluate model

All trained files are including in the Repository and model can be evaluated without training too using:

python label_image.py test_data/uranus/000.jpg

or any other test image from test_data/. You can add your own images to be evalauted with Model for Classification.

INCEPTION

1_c26y0gugmtvnskibfuja_w

The Inception network was an important milestone in the development of CNN classifiers. Prior to its inception (pun intended), most popular CNNs just stacked convolution layers deeper and deeper, hoping to get better performance.

The Inception network, on the other hand, was complex (heavily engineered). It used a lot of tricks to push performance; both in terms of speed and accuracy. Its constant evolution led to the creation of several versions of the network.

The below image is the “naive” inception module. It performs convolution on an input, with 3 different sizes of filters (1x1, 3x3, 5x5). Additionally, max pooling is also performed. The outputs are concatenated and sent to the next inception module.

inception

CELESTIAL BODIES

An astronomical object or celestial object is a naturally occurring physical entity, association, or structure that exists in the observable universe. [1] In astronomy, the terms object and body are often used interchangeably. However, an astronomical body or celestial body is a single, tightly bound, contiguous entity, while an astronomical or celestial object is a complex, less cohesively bound structure, which may consist of multiple bodies or even other objects with substructures.

Examples of astronomical objects include planetary systems, star clusters, nebulae, and galaxies, while asteroids, moons, planets, and stars are astronomical bodies. A comet may be identified as both body and object: It is a body when referring to the frozen nucleus of ice and dust, and an object when describing the entire comet with its diffuse coma and tail.

GALAXIES

A galaxy is an enormous collection of interstellar dust, gas, stellar remnant, stars along with their own solar systems held together by gravity. Earth is situated in the Milky Way galaxy. The Milky Way is a spiral-shaped galaxy with a diameter ranging 100,000 and 180,000 light-years. Our galaxy was thought to contain all the stars in the universe until, in 1920, Edwin Hubble observed that the Milky Way is one of many galaxies in the universe and that every galaxy contains potentially billions or trillions of stars. To this day, only a small fraction of galaxies have been discovered.

In recent years, astronomy has become an immensely data-rich field with numerous digital sky surveys across a wide range of wavelengths. For example, the Sloan Digital Sky Survey will produce over 50,000,000 images of galaxies in the near future. Studying the morphology of galaxies is one of the most important aspects of answering many of the questions to which humanity does not yet know the answer, namely the creation of the universe. Scientists can understand the origin, formation, and evolution of galaxies by classifying galaxies by their structural appearance. The morphological classification of galaxies in a large database is important to help astronomers reduce classification errors and to help them collect statistical and observational data and discover the mystery of nature in general.

Astronomers can look into time and space as far as billions of light years away from Earth and explore millions of galaxies far away using space telescopes that are much more powerful than our eyesight.

galaxies Figure 1: Three classes of galaxy morphological. From left to right: Elliptical Shaped Galaxy, Spiral Shaped Galaxy and Irregular Shaped Galaxy (en.Wikipedia.org, 2006)

There are different types of galaxies:

  • ELLIPTICAL

    An elliptical galaxy is a type of galaxy having an approximately ellipsoidal shape and a smooth, nearly featureless image.
    Unlike flat spiral galaxies with organization and structure, elliptical galaxies are more three-dimensional, without much structure, and their stars are in somewhat random orbits around the center.

  • SPIRAL

    Spiral galaxies form a class of galaxy originally described by Edwin Hubble in his 1936 work The Realm of the Nebulae and, as such, form part of the Hubble sequence. Most spiral galaxies consist of a flat, rotating disk containing stars, gas and dust, and a central concentration of stars known as the bulge.

  • IRREGULAR

    An irregular galaxy is a galaxy that does not have a distinct regular shape, unlike a spiral or an elliptical galaxy. Irregular galaxies do not fall into any of the regular classes of the Hubble sequence, and they are often chaotic in appearance, with neither a nuclear bulge nor any trace of spiral arm structure.

PLANETS

A planet is an astronomical body orbiting a star or stellar remnant that is massive enough to be rounded by its own gravity, is not massive enough to cause thermonuclear fusion, and has cleared its neighbouring region of planetesimals. There are a total of 8 planets in our solar system:

  • Mercury: is the closest planet to the sun and the smallest planet in our solar system. Mercury has a rotation of 88 days around the sun. The close proximity of Mercury to the sun causes the surface temperatures to reach a high of 840°F during the day and hundreds of degrees below the freezing point at night. Mercury does not have an atmosphere due to the extreme temperatures. Without an atmosphere, the surface of Mercury is covered with pockmarks and craters from meteor impacts.

mercury

  • Venus: is the second planet from the sun. Venus primarily consists of carbon dioxide which makes the planet toxic. The atmospheric pressure of Venus is capable of crushing anyone who landed on its surface. Venus can be seen by the naked eye from Earth. Thick clouds shroud Venus, making it difficult to see the details of the planet's surface.

venus

  • Earth: also known as "Terra", is the third planet from the sun. Earth is the only planet in our solar system that is capable of sustaining life. The rotation of Earth around the sun is approximately 365 days. The estimated age of the Earth is 4.54 billion years.

earth

  • Mars: is the fourth planet from the sun. Mars is also known as the "red planet" because of the reddish color formed by the high iron content in its soil. The rotation of Mars around the sun is approximately 686 days. The thin atmosphere of Mars consists mainly of carbon dioxide which makes it unsuitable for sustaining life. Scientists believed Mars to have once been capable of sustaining life and still might be able to in the future.

mars

  • Jupiter: the largest planet in our system, the mysteries of Jupiter has fascinated astronomers and non-astronomers alike for centuries. Poisonous gases completely cover its surface, hiding what lies beneath and violent storms prevent any landings of probes onto or images taken of the giant planet. Jupiter's atmosphere has been determined to be similar to that of the sun containing elements of hydrogen and helium.

jupiter

  • Saturn: first viewed via telescope in 1610 by Galileo Galilei, is the 6th planet in our solar system from the sun. Like Jupiter, its atmosphere is composed primarily of helium and hydrogen and it is the only planet discovered so far that has a lower density than water, approximately 30% lower. It is surrounded by a set of 9 whole rings and 3 broken rings that are comprised mainly of ice, rock, and space "dust".

saturn

  • Uranus: also known as the "sideways planet" because of its awkward rotation, is the 7th planet in our solar system from the sun. Uranus' North and South poles are located where other planets equators are. Seasons are 20 years long due to Uranus' strange rotation. The bluish color of Uranus' atmosphere is caused by methane gases, but the main elements are helium and hydrogen.

uranus

  • Neptune: is known as the windiest planet in our solar system and 8th furthermost known "planet" from our sun. It has a revolution around the sun of 165 Earth years. Like Uranus, Neptune has high traces of methane in its atmosphere, which contributes to its blue color. It is believed there is a second "unknown" element, though, that makes it a much brighter blue than Uranus.

neptune

MOONS

A natural satellite, or moon, is, in the most common usage, an astronomical body that orbits a planet or minor planet (or sometimes another small Solar System body).

  • Earth's moon: is a gravity rounded astronomical body orbiting the Earth and is the planet's only natural satellite. The Moon is thought to have formed about 4.51 billion years ago, not long after Earth. The Moon is in synchronous rotation with Earth, and thus always shows the same side to Earth, the near side. The Moon's average orbital distance is 384,402 km (238,856 mi),[16][17] or 1.28 light-seconds.

Earth's moon

ASTEROIDS

Asteroids, sometimes called minor planets, are rocky, airless remnants left over from the early formation of our solar system about 4.6 billion years ago. Most of this ancient space rubble can be found orbiting the Sun between Mars and Jupiter within the main asteroid belt.

Asteroid

License

ritwik12/Celestial-bodies-detection is licensed under the GNU General Public License v3.0

Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

celestial-bodies-detection's People

Contributors

aquiline avatar attard-andrew avatar dependabot[bot] avatar henryzerocool avatar jackycodes avatar joshestein avatar kannandreams avatar laukikk avatar mgrinstein avatar prakhar314 avatar priyalekande avatar ritwik12 avatar sadavarterohit avatar sambhavipd avatar satyabrat35 avatar schadalapaka avatar shreya-pathak avatar shubby98 avatar ssahas avatar sudhanshu-chauhan avatar varunpusarla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

celestial-bodies-detection's Issues

Add test cases

We need more test cases to make our Model better while receiving PRs. Test cases can be then included as part of Travis.

Moon

Add feature to detect moon.

Deploy current webapp to project site

Need to evaluate different approaches to deploy web app which is a Python-based Flask backend app. The site will be deployed as a project site with gh-pages in the form of github.io

Add Training Data

There are few data available for Uranus, Mars and others. Having a good amount of training data increases accuracy also. Uranus is having only 20 images and for this model it should be at least 25 for better efficiency.

add .gitignore

while cloning the code, I found a .pyc file in the master branch! I feel like we should add a .gitignore file and add pyc file in it! please let me know if it sounds like a good idea, I will raise a PR for the same via separate branch

Classifying Celestial-bodies

The main purpose of this project when It started was to get as much possible info from a far-sighted image of interstellar space as possible. This project was meant to detect planets, stars, galaxies, etc from a single image.

With the advancement in cosmological science, it is possible to tell a lot from an image using heat signatures, colors of objects, size, etc.

For example:
http://curious.astro.cornell.edu/observational-astronomy/82-the-universe/stars-and-star-clusters/measuring-the-stars/389-what-can-we-learn-from-the-color-of-a-star-intermediate

One of the tasks could be to add classifications for:

  • Stars

  • Supernova

  • Nebula

  • Cluster of galaxies

Supress tensorflow warnings

$ python label_image.py test_data/uranus_1.jpg
WARNING:tensorflow:From label_image.py:10: FastGFile.__init__ (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
WARNING:tensorflow:From label_image.py:13: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

WARNING:tensorflow:From label_image.py:17: The name tf.GraphDef is deprecated. Please use tf.compat.v1.GraphDef instead.

2019-11-08 14:01:32.473545: W tensorflow/core/framework/op_def_util.cc:357] Op BatchNormWithGlobalNormalization is deprecated. It will cease to work in GraphDef version 9. Use tf.nn.batch_normalization().
WARNING:tensorflow:From label_image.py:22: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

2019-11-08 14:01:32.664871: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations:  SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.
2019-11-08 14:01:32.665248: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 8. Tune using inter_op_parallelism_threads for best performance.

Classify Satellites

We already have Moon classification. It would be better to have more Satellite.

Create GUI

Right now it is simply terminal based. A good GUI will make it a proper software instead of a mere tool.

Change Test data files names

It will be good to have test data the same way we have training data in specific folders with proper numbering like 000, 001 etc

Change Training data filenames

As of now all the files inside the training data are random names and most are the names of the objects which they are like "earth", "mars" etc which makes it look bad as we are classifying images here. Better to have names in numeric order like 01, 02, 03 and so on.

PS: It will require a script to change the names of files, don't do it manually :p

Classify Meteor and Meteorites

Though Meteor, Meteorides, and Meteorites are the same thing and are very similar to Asteroid too, we need to think of a way to classify them.

Meteoroids are lumps of rock or iron that orbit the sun, just as planets, asteroids, and comets do.
When meteoroids enter Earth's atmosphere (or that of another planet, like Mars) at high speed and burn up,
the fireballs or “shooting stars” are called meteors. 

A meteor is a streak of light in the sky caused by a meteoroid crashing through Earth's atmosphere. 
When a meteoroid survives a trip through the atmosphere and hits the ground, it's called a meteorite.

Irregular Galaxies

Feature request

Support for detecting irregular galaxies also.
Add training data for Irregular galaxies to detect

Comets

Add feature for comets detection and also add training data for it.

Update the README.md

it is showing error while running latest version of python and tensorflow.
some functions are moved to some other library in tensorflow.

Improve GUI (WebApp)

With #70 we now have GUI now which is based on Python and written in Flask. there is a good scope of improvements to the WebApp. Both logical and in frontend.

TensorFlow version in retrain.py

Hello, I am entirely new to TensorFlow, but I am trying to run the retrain script, and it looks like this file is not coded for TensorFlow 2.7.2, which is the version specified in the requirements.txt.

This is the error that I am getting:

Traceback (most recent call last):
  File "retrain.py", line 1062, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
AttributeError: module 'tensorflow' has no attribute 'app'

I was able to update the script using tf_upgrade_v2 (https://www.tensorflow.org/guide/migrate/upgrade) and run it, but this is the error that I am getting after doing that:

Looking for images in 'moon'
Looking for images in 'mars'
Looking for images in 'jupiter'
Looking for images in 'spiral'
Looking for images in 'uranus'
Looking for images in 'venus'
Looking for images in 'neptune'
Looking for images in 'earth'
Looking for images in 'mercury'
Looking for images in 'saturn'
Looking for images in 'asteroids'
Looking for images in 'elliptical'
100 bottleneck files created.
200 bottleneck files created.
300 bottleneck files created.
400 bottleneck files created.
500 bottleneck files created.
600 bottleneck files created.
700 bottleneck files created.
800 bottleneck files created.
900 bottleneck files created.
Traceback (most recent call last):
  File "retrain.py", line 1062, in <module>
    tf.compat.v1.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 312, in run
    _run_main(main, args)
  File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 258, in _run_main
    sys.exit(main(argv))
  File "retrain.py", line 812, in main
    final_tensor) = add_final_training_ops(len(image_lists.keys()),
  File "retrain.py", line 708, in add_final_training_ops
    bottleneck_input = tf.compat.v1.placeholder_with_default(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/ops/array_ops.py", line 3341, in placeholder_with_default
    return gen_array_ops.placeholder_with_default(input, shape, name)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 7013, in placeholder_with_default
    return placeholder_with_default_eager_fallback(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 7039, in placeholder_with_default_eager_fallback
    _result = _execute.execute(b"PlaceholderWithDefault", 1,
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/execute.py", line 72, in quick_execute
    raise e
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/execute.py", line 58, in quick_execute
    tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
TypeError: Originated from a graph execution error.

The graph execution error is detected at a node built at (most recent call last):
>>>  File retrain.py, line 1062, in <module>
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/platform/app.py, line 40, in run
>>>  File /usr/local/lib/python3.8/dist-packages/absl/app.py, line 312, in run
>>>  File /usr/local/lib/python3.8/dist-packages/absl/app.py, line 258, in _run_main
>>>  File retrain.py, line 779, in main
>>>  File retrain.py, line 254, in create_inception_graph
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/util/deprecation.py, line 552, in new_func
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/importer.py, line 407, in import_graph_def
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/importer.py, line 520, in _import_graph_def_internal
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/importer.py, line 251, in _ProcessNewOps
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/ops.py, line 3847, in _add_new_tf_operations
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/ops.py, line 3848, in <listcomp>
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/ops.py, line 3730, in _create_op_from_tf_operation
>>>  File /usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/ops.py, line 2101, in __init__

Error detected in node 'pool_3/_reshape' defined at: File "retrain.py", line 254, in create_inception_graph

TypeError: tf.Graph captured an external symbolic tensor. The symbolic tensor 'pool_3/_reshape:0' created by node 'pool_3/_reshape' is captured by the tf.Graph being executed as an input. But a tf.Graph is not allowed to take symbolic tensors from another graph as its inputs. Make sure all captured inputs of the executing tf.Graph are not symbolic tensors. Use return values, explicit Python locals or TensorFlow collections to access it. Please see https://www.tensorflow.org/guide/function#all_outputs_of_a_tffunction_must_be_return_values for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.