Spaces:
Sleeping
Sleeping
| from gradio_client import Client, handle_file | |
| cache = {} | |
| client = Client("gokaygokay/Florence-2", verbose=False) | |
| def see_url(url): | |
| result = client.predict( | |
| image=handle_file(url), | |
| task_prompt="More Detailed Caption", | |
| text_input=None, | |
| model_id="microsoft/Florence-2-large", | |
| api_name="/process_image" | |
| ) | |
| return(result[0].replace("{'<MORE_DETAILED_CAPTION>': '", "").replace("'}", "")) | |
| def see_file(fp): | |
| if fp in cache: | |
| return cache[fp] | |
| result = client.predict( | |
| image=handle_file(fp), | |
| task_prompt="More Detailed Caption", | |
| text_input=None, | |
| model_id="microsoft/Florence-2-large", | |
| api_name="/process_image" | |
| ) | |
| r=result[0].replace("{'<MORE_DETAILED_CAPTION>': '", "").replace("'}", "") | |
| cache[fp] = r | |
| return r |