Location Classification of Indian Cities: A Streamlit App

Jul 4, 2024 | Educational

Welcome to the exciting realm of image classification! You might have come across situations where you have an image, and you’re curious about its whereabouts. This blog explores a fascinating Streamlit app designed to detect the location of an Indian city in an uploaded image using a deep learning model trained on 10,500 images across five vibrant Indian cities. Let’s jump straight into how you can use this powerful tool.

How to Use the App

Follow these simple steps to get started:

  1. Clone the GitHub repository by executing the command:
  2. git clone https://github.com/shahdivax/Location-Classification-of-Indian-Cities.git --branch master
  3. Next, install the required libraries:
  4. pip install -r requirements.txt
  5. Now, run the app using the following command:
  6. streamlit run app.py
  7. For those interested in the Flask version, switch to the Flask directory and run:
  8. cd Flask
    flask run
  9. Upload an image in JPG or JPEG format.
  10. The app will process and display your uploaded image while predicting the city’s location.
  11. Finally, you’ll see the predicted location along with the accuracy percentage of the prediction.

Bear in mind that the app may not perform well with unclear images or those lacking distinctive city landmarks.

Understanding the Code Behind the App

The code for this app is crafted in Python using several libraries to build a seamless user interface and process images efficiently. Imagine this system as a sophisticated chef in a kitchen:

  • The chef (your code) begins by gathering all the necessary ingredients (libraries), including:
    • Streamlit: This is the chef’s kitchen where all the cooking happens — building the user interface.
    • TensorFlow and Keras: These are the tools used to chop and prepare the images (load the pretrained model).
    • Numpy and Random: These are the trusty sous chefs that assist in data processing and adding a splash of flair (random color selection).
  • Once the ingredients are prepped, the chef gets to work by following these steps:
    • Load the trained deep learning model (the main course).
    • Define the class labels for the five Indian cities (ingredient labels).
    • Set a minimum accuracy threshold for predictions (quality control).
    • Create a function to process uploaded images (cooking process).
    • Design the Streamlit app interface with a file uploader (presenting the dish).
    • After processing, the chef presents the predicted location and accuracy (serving the meal).

Live Demo

For those eager to see the app in action, check out the live demo here.

Troubleshooting

If you encounter issues, consider the following troubleshooting tips:

  • Ensure that all libraries are correctly installed.
  • Verify that the image format is either JPG or JPEG.
  • Check if the uploaded images are clear and have discernible city landmarks for better accuracy.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Future Work

This app has the potential for endless improvements. Future enhancements could include increasing the dataset size and fine-tuning the pre-trained model to further boost its accuracy. Additionally, incorporating landmark recognition capabilities could significantly elevate the app’s performance.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox