hprasath/image-processing
0
1import requests2 3# Define the image URL4image_url = "https://utfs.io/f/47589c6c-6ce0-4baf-b75d-b1ec5d4d9dda-213j1w.jpg"5audio_url = "https://utfs.io/f/b84a84a2-b68f-49c5-8b7c-d76d894f6d3a-c5qjj4.wav"6video_url = "https://utfs.io/f/ef6c037f-fa61-471a-8956-562bc2d62531-fzxs1i.mp4"7family_url = "https://i.pinimg.com/originals/b2/20/14/b22014ca275e94097386aab222469caf.jpg"8 9 10# Define the URLs of the three nodes11extract_text_url = "http://127.0.0.1:5000/extractText"12extract_audio_text_url = "http://127.0.0.1:5000/extractAudioText"13get_image_embedding_url = "http://127.0.0.1:5000/getImageEmbedding"14get_text_embedding_url = "http://127.0.0.1:5000/getTextEmbedding"15get_text_description_embedding_url = "http://127.0.0.1:5000/getTextDescriptionEmbedding"16get_audio_embedding_url = "http://127.0.0.1:5000/getAudioEmbedding"17get_audio_extracted_text_url = "http://127.0.0.1:5000/getAudioExtractedText"18get_video_embedding_url = "http://127.0.0.1:5000/getVideoEmbedding"19get_object_detection_url = "http://127.0.0.1:5000/detectObjects"20get_similarity_score_url = "http://127.0.0.1:5000/getSimilarityScore"21get_face_locations_url = "http://127.0.0.1:5000/getFaceLocations"22 23# Make requests to each node with the image URL24try:25 list=[]26 27 response_text = requests.post(extract_audio_text_url, json={"audio_url": audio_url})28 extracted_text = response_text.json()["transcription"]29 list.append({"length of text":len(extracted_text)})30 31 # # Request to extract text32 # response_text = requests.post(extract_text_url, json={"imageUrl": image_url})33 # extracted_text = response_text.json().get("extracted_text")34 # list.append({"length of text":len(extracted_text)})35 36 # # Request to get image embedding37 # response_image_embedding = requests.post(get_image_embedding_url, json={"imageUrl": image_url})38 # image_embedding = response_image_embedding.json().get("image_embedding")39 # list.append({"length of image_embedding":len(image_embedding)})40 41 # # Request to get text embedding42 # response_text_embedding = requests.post(get_text_embedding_url, json={"text": extracted_text})43 # text_embedding = response_text_embedding.json().get("text_embedding")44 # list.append({"length of text_embedding":len(text_embedding)})45 46 # # Request to get text description embedding47 # response_text_description_embedding = requests.post(get_text_description_embedding_url, json={"text": "a image of mobile phone"})48 # text_description_embedding = response_text_description_embedding.json().get("text_description_embedding")49 # list.append({"length of text_description_embedding":len(text_description_embedding)})50 51 # # Request to get audio embedding52 # response_audio_embedding = requests.post(get_audio_embedding_url, json={"audioUrl": audio_url})53 # audio_embedding = response_audio_embedding.json().get("audio_embedding")54 # list.append({"length of audio_embedding":len(audio_embedding)})55 56 # Request to get video embedding57 response_video_embedding = requests.post(get_video_embedding_url, json={"videoUrl": video_url})58 video_embedding = response_video_embedding.json().get("video_embedding")59 list.append({"length of video_embedding":(video_embedding)})60 61 # # Request to get object detection62 # response_object_detection = requests.post(get_object_detection_url, json={"imageUrl": image_url})63 # object_detection = response_object_detection.json().get("object_detection_results")64 # list.append({"length of object_detection":len(object_detection)})65 66 # # Request to get similarity score67 # response_similarity_score = requests.post(get_similarity_score_url, json={"embedding1": text_description_embedding, "embedding2": image_embedding})68 # similarity_score = response_similarity_score.json().get("similarity_score")69 # list.append({"similarity_score":similarity_score})70 71 # # Request to get face locations72 # response_face_locations = requests.post(get_face_locations_url, json={"imageUrl": family_url})73 # face_locations = response_face_locations.json().get("face_locations")74 # list.append({"face_locations":face_locations})75 print(list)76except Exception as e:77 print("Error:", e)78 