Rename folder + remove coloring on omniparseragent printouts

This commit is contained in:
Thomas Dhome-Casanova
2025-01-29 22:44:23 -08:00
parent 746507b9d9
commit 7800a24b27
17 changed files with 0 additions and 1772 deletions

1
computer_use_demo/gradio/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
tmp/

View File

@@ -1,17 +0,0 @@
"""
Define some colorful stuffs for better visualization in the chat.
"""
# Define the RGB colors for each letter
colors = {
'S': 'rgb(106, 158, 210)',
'h': 'rgb(111, 163, 82)',
'o': 'rgb(209, 100, 94)',
'w': 'rgb(238, 171, 106)',
'U': 'rgb(0, 0, 0)',
'I': 'rgb(0, 0, 0)',
}
colorful_text_vlm = "**OmniParser Agent**"
colorful_text_user = "**User**"

View File

@@ -0,0 +1,51 @@
'''
python -m omniparserserver --som_model_path ../../weights/icon_detect_v1_5/model_v1_5.pt --caption_model_name florence2 --caption_model_path ../../weights/icon_caption_florence --device cuda --BOX_TRESHOLD 0.05
'''
import sys
import os
import time
from fastapi import FastAPI
from pydantic import BaseModel
import argparse
import uvicorn
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root_dir)
from util.omniparser import Omniparser
def parse_arguments():
parser = argparse.ArgumentParser(description='Omniparser API')
parser.add_argument('--som_model_path', type=str, default='../../weights/icon_detect_v1_5/model_v1_5.pt', help='Path to the som model')
parser.add_argument('--caption_model_name', type=str, default='florence2', help='Name of the caption model')
parser.add_argument('--caption_model_path', type=str, default='../../weights/icon_caption_florence', help='Path to the caption model')
parser.add_argument('--device', type=str, default='cpu', help='Device to run the model')
parser.add_argument('--BOX_TRESHOLD', type=float, default=0.05, help='Threshold for box detection')
parser.add_argument('--host', type=str, default='0.0.0.0', help='Host for the API')
parser.add_argument('--port', type=int, default=8000, help='Port for the API')
args = parser.parse_args()
return args
args = parse_arguments()
config = vars(args)
app = FastAPI()
omniparser = Omniparser(config)
class ParseRequest(BaseModel):
base64_image: str
@app.post("/parse/")
async def parse(parse_request: ParseRequest):
print('start parsing...')
start = time.time()
dino_labled_img, parsed_content_list = omniparser.parse(parse_request.base64_image)
latency = time.time() - start
print('time:', latency)
return {"som_image_base64": dino_labled_img, "parsed_content_list": parsed_content_list, 'latency': latency}
@app.get("/probe/")
async def root():
return {"message": "Omniparser API ready"}
if __name__ == "__main__":
uvicorn.run("remote_request:app", host=args.host, port=args.port, reload=True)