Spaces:
Sleeping
Sleeping
Pushpanjali
commited on
Commit
·
b6c906b
1
Parent(s):
a0aad55
adding files
Browse files- app.py +4 -2
- llm_function.py +13 -2
app.py
CHANGED
|
@@ -43,12 +43,14 @@ gr.Interface(
|
|
| 43 |
inputs=[gr.Image(type="filepath" , interactive = True), gr.Image(type="filepath" , interactive = True)],
|
| 44 |
# outputs=[gr.Image(), gr.Image()],
|
| 45 |
# outputs = ["text" , "text"] ,
|
| 46 |
-
outputs = [gr.Markdown(label = "VLM" , show_copy_button = True
|
| 47 |
title="Blueprint Comparison : VLM & SEG-VLM",
|
| 48 |
description="Upload two construstion blueprints to know differences between them." ,
|
| 49 |
flagging_mode = "never",
|
| 50 |
fill_width = True ,
|
| 51 |
submit_btn = "Compare",
|
| 52 |
show_progress = "full",
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
).launch(pwa = True)
|
|
|
|
| 43 |
inputs=[gr.Image(type="filepath" , interactive = True), gr.Image(type="filepath" , interactive = True)],
|
| 44 |
# outputs=[gr.Image(), gr.Image()],
|
| 45 |
# outputs = ["text" , "text"] ,
|
| 46 |
+
outputs = [gr.Markdown(label = "##VLM" , show_copy_button = True, container = True , height = 300) , gr.Markdown(label = "##SEG-VLM" , show_copy_button = True , container = True , height = 300)],
|
| 47 |
title="Blueprint Comparison : VLM & SEG-VLM",
|
| 48 |
description="Upload two construstion blueprints to know differences between them." ,
|
| 49 |
flagging_mode = "never",
|
| 50 |
fill_width = True ,
|
| 51 |
submit_btn = "Compare",
|
| 52 |
show_progress = "full",
|
| 53 |
+
theme = "soft",
|
| 54 |
+
analytics_enabled = True
|
| 55 |
|
| 56 |
+
).launch(pwa = True , share = True)
|
llm_function.py
CHANGED
|
@@ -4,6 +4,7 @@ import anthropic
|
|
| 4 |
import base64
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
import cv2
|
|
|
|
| 7 |
|
| 8 |
load_dotenv()
|
| 9 |
client = anthropic.Anthropic(api_key= os.getenv('ANTHROPIC_API_KEY'))
|
|
@@ -22,11 +23,18 @@ def encode_image(image_path):
|
|
| 22 |
return base64.b64encode(image_file.read()).decode("utf-8")
|
| 23 |
# return base64.b64encode(image_path.getvalue()).decode("utf-8")
|
| 24 |
|
|
|
|
| 25 |
def chat_claude(prompt , image1 , image2 ) :
|
| 26 |
# print("image 1" , image1)
|
| 27 |
image1_data = encode_image(image1)
|
| 28 |
# print("image 1 data" , image1_data)
|
| 29 |
image2_data = encode_image(image2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
message = client.messages.create(
|
| 31 |
model="claude-3-opus-20240229",
|
| 32 |
max_tokens = 4096,
|
|
@@ -42,7 +50,9 @@ def chat_claude(prompt , image1 , image2 ) :
|
|
| 42 |
"type": "image",
|
| 43 |
"source": {
|
| 44 |
"type": "base64",
|
| 45 |
-
"media_type": "image/jpeg",
|
|
|
|
|
|
|
| 46 |
"data": image1_data,
|
| 47 |
},
|
| 48 |
},
|
|
@@ -54,7 +64,8 @@ def chat_claude(prompt , image1 , image2 ) :
|
|
| 54 |
"type": "image",
|
| 55 |
"source": {
|
| 56 |
"type": "base64",
|
| 57 |
-
"media_type": "image/jpeg",
|
|
|
|
| 58 |
"data": image2_data,
|
| 59 |
},
|
| 60 |
},
|
|
|
|
| 4 |
import base64
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
import cv2
|
| 7 |
+
from mimetypes import MimeTypes
|
| 8 |
|
| 9 |
load_dotenv()
|
| 10 |
client = anthropic.Anthropic(api_key= os.getenv('ANTHROPIC_API_KEY'))
|
|
|
|
| 23 |
return base64.b64encode(image_file.read()).decode("utf-8")
|
| 24 |
# return base64.b64encode(image_path.getvalue()).decode("utf-8")
|
| 25 |
|
| 26 |
+
|
| 27 |
def chat_claude(prompt , image1 , image2 ) :
|
| 28 |
# print("image 1" , image1)
|
| 29 |
image1_data = encode_image(image1)
|
| 30 |
# print("image 1 data" , image1_data)
|
| 31 |
image2_data = encode_image(image2)
|
| 32 |
+
mime = MimeTypes()
|
| 33 |
+
image1_media_type =mime.guess_type(image1)[0]
|
| 34 |
+
image2_media_type =mime.guess_type(image2)[0]
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
message = client.messages.create(
|
| 39 |
model="claude-3-opus-20240229",
|
| 40 |
max_tokens = 4096,
|
|
|
|
| 50 |
"type": "image",
|
| 51 |
"source": {
|
| 52 |
"type": "base64",
|
| 53 |
+
# "media_type": "image/jpeg",
|
| 54 |
+
"media_type": image1_media_type,
|
| 55 |
+
|
| 56 |
"data": image1_data,
|
| 57 |
},
|
| 58 |
},
|
|
|
|
| 64 |
"type": "image",
|
| 65 |
"source": {
|
| 66 |
"type": "base64",
|
| 67 |
+
# "media_type": "image/jpeg",
|
| 68 |
+
"media_type": image2_media_type,
|
| 69 |
"data": image2_data,
|
| 70 |
},
|
| 71 |
},
|