ParkingGPT - Your AI Parking Copilot
Tags: openai, llm, azure, ai
Published: 2024-01-13 23:41:33

About 10 months (March, 2023) ago, I got a mention in a <a href="https://twitter.com/simonwaight/status/1630787390393704448">tweet</a> from one of my good friends and our local community leader, <a href="https://twitter.com/simonwaight">Simon Waight</a>. It was about solving a complex parking problem with Computer Vision. I bookmarked this interesting challenge and made it as a part of my <strong>want-to-do</strong> list. After a month, I picked this up and started to think as how I would like to solve this problem. I faced several problems which I have mentioned later in this blog post but finally managed to create this small yet useful cross-platform app (<em>or copilot or gpt or whatever you want to call it</em>) for everyone living in Australia. While there's a big need of improvements and additional features, it is live and opensource. You may consider it as <em>a new year gift from me</em>.

<a href="https://twitter.com/simonwaight/status/1630787390393704448"><img class="aligncenter wp-image-31891 size-full" src="https://arafattehsin.com/wp-content/uploads/2024/01/Tweet.png" alt="Tweet by Simon Waight" width="538" height="874" /></a>
<h2>Learning from my failures</h2>
As I mentioned earlier, it was just a tweet which triggered this idea. However, there were many hiccups in its development. Someone rightly said that success never comes easy. As the world is going through a rapid change of how we develop, use and interact with technology, picking up these challenges can be daunting, time-consuming and hard. Initially, as soon as I picked it up, I opted for the latest and finest technology of that time for Computer Vision. I chose <a href="https://azure.microsoft.com/blog/announcing-a-renaissance-in-computer-vision-ai-with-microsofts-florence-foundation-model/?WT.mc_id=AI-MVP-5003464">Project Florence</a> by Microsoft which is a large foundational model for Vision. The reason why I chose this is because I wanted to use the <a href="https://portal.vision.cognitive.azure.com/demo/dense-captioning">dense captions</a> capability of this model.

However, after trying out different techniques, I failed as it couldn't do the proper OCR of the parking signs. Later on, I was suggested by one of the product team members to use Form Recognizer (which is now called <a href="https://azure.microsoft.com/products/ai-services/ai-document-intelligence?WT.mc_id=AI-MVP-5003464">Azure AI Document Intelligence</a>). I tried with that too but couldn't get any success either. The problem I was getting with Form Recognizer was that the text was not correct all the time. It used to be messed up sometimes. To combat this problem, I decided to use a combo approach which means that I used Form Recognizer for OCR (with a bit of gibberish results) and then corrected them with GPT-3. This worked for a few signs but failed miserably for others. Basically, the success rate was 50%. I wanted something robust that would solve this problem for us without any training of a custom dataset.

Finally, the time came when I witnessed the launch of OpenAI's GPT-4 with Vision followed by the support for the same in Azure OpenAI Service. It felt like my wish came true with time, but then I had to wait because I had so many other things planned esp. the year end tasks and the family holidays. 🎈

Considering all of it, I kept a dedicated slot between my personal time to work on this as I really wanted to finish it off before my work begins in January 2024. So, here I am, I think I achieved what I planned. I created a <strong>ParkingGPT </strong>for all of my fellow Aussies to decide when they can park or not. It's very initial stage and currently I have just tested with the parking signs within New South Wales. However, if you are based in any other state then please feel free to give it a shot and let me know your feedback. 🙏

<img class="aligncenter wp-image-31886" src="https://arafattehsin.com/wp-content/uploads/2024/01/AI-Parking-Copilot.jpg" alt="AI Parking Copilot" width="500" height="500" />
<h2>ParkingGPT</h2>
<a href="https://github.com/arafattehsin/ParkingGPT">ParkingGPT</a> enables you to decide whether you want to park or not, all using the power of Vision AI &amp; LLM. This uses the newly released <a href="https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/gpt-4-turbo-with-vision-on-azure-openai-service/ba-p/3979933?WT.mc_id=AI-MVP-5003464">GPT-4 Turbo with Vision</a>. With ParkingGPT, you can easily identify parking signs and make informed decisions about where to park. Whether you’re a driver looking for a convenient parking spot or a parking enforcement officer looking to enforce parking regulations, ParkingGPT is your AI parking copilot.

This app just has two main features. It either allows you to capture a photo of a parking sign from your camera or it lets you pick it up from the photo gallery.
<table style="width: 100%;">
<tbody>
<tr>
<td><img class="aligncenter size-full wp-image-31893" src="https://arafattehsin.com/wp-content/uploads/2024/01/homescreen.png" alt="Home Screen of ParkingGPT" width="308" height="630" /></td>
<td><img class="aligncenter size-full wp-image-31894" src="https://arafattehsin.com/wp-content/uploads/2024/01/pick.png" alt="Pick a photo screen of ParkingGPT" width="308" height="632" /></td>
<td><img class="aligncenter size-full wp-image-31895" src="https://arafattehsin.com/wp-content/uploads/2024/01/result.png" alt="Parking Result of ParkingGPT" width="309" height="631" /></td>
</tr>
</tbody>
</table>
<h3>Technical Implementation</h3>
It is quite straight forward as you can see from the repo. I have tried my best to follow the best practices for .NET MAUI and how you usually develop apps. There may be certain negative cases which I may have missed, such as writing an effective prompt of ignoring non-parking sign images but overall, it works well.

This app takes an image (either from the camera or from the gallery) and then converts it into base64 encoded string. This is then sent to OpenAI API's for processing and returned with the response. This app is good to work with both Azure OpenAI and OpenAI. All you need is the API endpoint key for it to run. The API endpoint key stays in your app's specific storage which means that you do not have to enter it again and again.

{% embed https://youtube.com/shorts/s_H4MVvEfCs?feature=share %}

<h3 dir="auto" tabindex="-1">Some common FAQs</h3>
<p dir="auto"><strong>Is it published on a Google Play Store?</strong></p>
No, but you can request me for the .apk package by just commenting on this post and sideload it to your Android for now. If there's much interest, I can think of publishing it to the store.
<p dir="auto"><strong>Is it published on an Apple App Store?</strong></p>
No. I do not own a Macbook which restricts me from creating a package (or .ipa) for this app. The developer program subscription is too expensive for a hobbyist but I will see.
<p dir="auto"><strong>Does it work seamlessly with multiple parking signs?</strong></p>
I have tried 2 to 3 ones and it works fine. However, I am not sure how it would react to the more than 2 or 3 signs. <em>I am still testing it.</em>
<p dir="auto"><strong>Is it smart enough to make decision based upon the no parking signs and parking signs?</strong></p>
Not for now. I will see this for future.

<hr />

If you are a developer then the code is there for you as opensource to see how I have done it. As a part of my mission to empower every developer with necessary applied AI skills, I have done this in my personal time. Please do not forget to star ⭐ the repo if you like and share it among your friends so others can get an idea on how to create small but useful utilities like ParkingGPT.

Until next time.