Spaces:
Runtime error
Runtime error
# works with uploaded image URLs | |
from moderator_mc import moderate_image # uses moderate-content api | |
from caption import caption_from_url # generates captions | |
from vector_search import topic_from_caption | |
def process_image(image_url): | |
# Call the moderation function | |
moderation_result = moderate_image(image_url) | |
# If the moderator returns True, return "moderated" | |
# if moderation_result: #for azure | |
if moderation_result == 3: # mc api | |
return "moderated" | |
# If the moderator returns False, pass the URL to the captioner function | |
else: | |
image_caption = caption_from_url(image_url) | |
topic = topic_from_caption(image_caption) | |
answer = f"Caption: {image_caption}. Topic: {topic}" | |
return answer | |