Upload 5 files
Browse files- .gitattributes +1 -0
- 3000.jpeg +3 -0
- app.py +154 -0
- original (8).jpg +0 -0
- requirements.txt +7 -0
- traffic.jpg +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
3000.jpeg filter=lfs diff=lfs merge=lfs -text
|
3000.jpeg
ADDED
![]() |
Git LFS Details
|
app.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import base64
|
2 |
+
import io
|
3 |
+
import cv2
|
4 |
+
import requests
|
5 |
+
import json
|
6 |
+
import gradio as gr
|
7 |
+
import os
|
8 |
+
from PIL import Image
|
9 |
+
import numpy as np
|
10 |
+
from PIL import ImageOps
|
11 |
+
|
12 |
+
# Accessing a specific environment variable
|
13 |
+
api_key = os.environ.get('devisionx')
|
14 |
+
|
15 |
+
# Checking if the environment variable exists
|
16 |
+
if not api_key:
|
17 |
+
print("devisionx environment variable is not set.")
|
18 |
+
exit()
|
19 |
+
|
20 |
+
# Define a function to call the API and get the results
|
21 |
+
|
22 |
+
def base64str_to_PILImage(base64str):
|
23 |
+
base64_img_bytes = base64str.encode('utf-8')
|
24 |
+
base64bytes = base64.b64decode(base64_img_bytes)
|
25 |
+
bytesObj = io.BytesIO(base64bytes)
|
26 |
+
return ImageOps.exif_transpose(Image.open(bytesObj))
|
27 |
+
|
28 |
+
def get_results(image, prompt):
|
29 |
+
threshold = 0.5
|
30 |
+
|
31 |
+
# Convert the NumPy array to PIL image
|
32 |
+
image = Image.fromarray(image)
|
33 |
+
|
34 |
+
# Convert the image to base64 string
|
35 |
+
with io.BytesIO() as output:
|
36 |
+
image.save(output, format="JPEG")
|
37 |
+
base64str = base64.b64encode(output.getvalue()).decode("utf-8")
|
38 |
+
|
39 |
+
# Prepare the payload (Adjust this part according to the API requirements)
|
40 |
+
payload = json.dumps({"base64str": base64str, "classes": prompt})
|
41 |
+
|
42 |
+
# Send the request to the API
|
43 |
+
response = requests.put(api_key, data=payload)
|
44 |
+
|
45 |
+
# Parse the JSON response
|
46 |
+
data = response.json()
|
47 |
+
print(response.status_code)
|
48 |
+
print(data)
|
49 |
+
|
50 |
+
# Access the values (Adjust this part according to the API response format)
|
51 |
+
output_image_base64 = data['firstName'] # Assuming the API returns the output image as base64
|
52 |
+
|
53 |
+
|
54 |
+
# Convert the output image from base64 to PIL and then to NumPy array
|
55 |
+
output_image = base64str_to_PILImage(output_image_base64)
|
56 |
+
output_image = np.array(output_image)
|
57 |
+
|
58 |
+
return output_image
|
59 |
+
|
60 |
+
|
61 |
+
# Define the input components for Gradio (adding a new input for the prompt)
|
62 |
+
# image_input = gr.inputs.Image()
|
63 |
+
# text_input = gr.inputs.Textbox(label="Prompt") # New input for the text prompt
|
64 |
+
|
65 |
+
|
66 |
+
# # Define the output components for Gradio (including both image and text)
|
67 |
+
# outputs = gr.Image(type="numpy", label="Output Image")
|
68 |
+
|
69 |
+
# Define the text description within an HTML <div> element
|
70 |
+
description_html = """
|
71 |
+
<!DOCTYPE html>
|
72 |
+
<html>
|
73 |
+
<head>
|
74 |
+
<title>Tuba AI Auto-Annotation </title>
|
75 |
+
</head>
|
76 |
+
<body>
|
77 |
+
<h1>Tuba AI Auto-Annotation 🚀</h1>
|
78 |
+
<h2>Saving Time, Bounding Boxes at a Time </h2>
|
79 |
+
<h2>Introduction</h2>
|
80 |
+
<p>Welcome to the world of DevisionX, where AI meets vision to revolutionize annotation. Our mission is to make computer vision accessible to all, and this README is your gateway to understanding how our auto-annotation model can change the way you work.</p>
|
81 |
+
<h2>Meet Tuba.AI - Your Partner in Vision</h2>
|
82 |
+
<h3>What is Tuba?</h3>
|
83 |
+
<p>Tuba is the secret sauce behind DevisionX, your no-code/low-code companion for all things computer vision. It's your toolkit for labeling, training data, and deploying AI-vision applications faster and easier than ever before.</p>
|
84 |
+
<ul>
|
85 |
+
<li>No-Code/Low-Code: Say goodbye to complex coding. Tuba's user-friendly interface makes it accessible to everyone.</li>
|
86 |
+
<li>Labeling Made Easy: Annotate your data effortlessly with Tuba's intuitive tools.</li>
|
87 |
+
<li>Faster Deployment: Deploy your AI models with ease, whether you're building a standalone app or integrating within an existing one.</li>
|
88 |
+
<li>State-of-the-Art Technology: Tuba is powered by the latest AI tech and follows production-ready standards.</li>
|
89 |
+
</ul>
|
90 |
+
<h2>The DevisionX Auto-Annotation</h2>
|
91 |
+
<p>Our auto-annotation model is a game-changer. It takes input text and images, weaving them together to generate precise bounding boxes. This AI marvel comes with a plethora of benefits:</p>
|
92 |
+
<ul>
|
93 |
+
<li>Time Saver: Say goodbye to hours of manual annotation. Let our model do the heavy lifting.</li>
|
94 |
+
<li>Annotation Formats: It speaks the language of YOLO and COCO, making it versatile for various projects.</li>
|
95 |
+
<li>Human Assistance: While it's incredibly efficient, it also respects human creativity and can be your reliable assistant.</li>
|
96 |
+
</ul>
|
97 |
+
<h2>Let's Build Together</h2>
|
98 |
+
<p>We are here to redefine the way you approach computer vision. Join us in this exciting journey, where AI meets creativity, and innovation knows no bounds.</p>
|
99 |
+
<p>Get started today and be a part of the future of vision.</p>
|
100 |
+
</body>
|
101 |
+
</html>
|
102 |
+
|
103 |
+
|
104 |
+
|
105 |
+
"""
|
106 |
+
title = "autoannotation"
|
107 |
+
|
108 |
+
description = "This is a project description. It demonstrates how to use Gradio with an image and text input to interact with an API."
|
109 |
+
|
110 |
+
import os
|
111 |
+
examples = [
|
112 |
+
["traffic.jpg", 'person,car,traffic sign,traffic light'],
|
113 |
+
["3000.jpeg",'person,car,traffic sign,traffic light']
|
114 |
+
]
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
# Create a Blocks object and use it as a context manager
|
120 |
+
with gr.Blocks() as demo:
|
121 |
+
gr.Markdown(
|
122 |
+
"""
|
123 |
+
<div style="text-align: center;">
|
124 |
+
<h1>Tuba Autoannotation Demo</h1>
|
125 |
+
<h3>A prompt based controllable model for auto annotation </h3>
|
126 |
+
<h3>Saving Time, Bounding Boxes at a Time </h3>
|
127 |
+
Powered by <a href="https://Tuba.ai">Tuba</a>
|
128 |
+
</div>
|
129 |
+
"""
|
130 |
+
)
|
131 |
+
# Define the input components and add them to the layout
|
132 |
+
|
133 |
+
with gr.Row():
|
134 |
+
image_input = gr.inputs.Image()
|
135 |
+
output = gr.Image(type="numpy", label="Output Image")
|
136 |
+
|
137 |
+
# Define the output component and add it to the layout
|
138 |
+
with gr.Row():
|
139 |
+
text_input = gr.inputs.Textbox(label="Prompt")
|
140 |
+
with gr.Row():
|
141 |
+
button = gr.Button("Run")
|
142 |
+
|
143 |
+
# Define the event listener that connects the input and output components and triggers the function
|
144 |
+
button.click(fn=get_results, inputs=[image_input, text_input], outputs=output, api_name="get_results")
|
145 |
+
# Add the description below the layout
|
146 |
+
gr.Examples(
|
147 |
+
fn=get_results,
|
148 |
+
examples=examples,
|
149 |
+
inputs=[image_input, text_input],
|
150 |
+
outputs=[output]
|
151 |
+
)
|
152 |
+
gr.Markdown(description_html)
|
153 |
+
# Launch the app
|
154 |
+
demo.launch(share=False)
|
original (8).jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy
|
2 |
+
pydantic
|
3 |
+
matplotlib
|
4 |
+
opencv-python
|
5 |
+
DateTime
|
6 |
+
requests
|
7 |
+
gradio
|
traffic.jpg
ADDED
![]() |