diff --git a/MasterProject/MasterProject/settings.py b/MasterProject/MasterProject/settings.py index f937180..afd83fd 100644 --- a/MasterProject/MasterProject/settings.py +++ b/MasterProject/MasterProject/settings.py @@ -14,6 +14,7 @@ import environ import os +os.environ['CUDA_VISIBLE_DEVICES'] = '' env = environ.Env() environ.Env.read_env() diff --git a/MasterProject/homeapp/utils.py b/MasterProject/homeapp/utils.py index 0228949..ae59e1c 100644 --- a/MasterProject/homeapp/utils.py +++ b/MasterProject/homeapp/utils.py @@ -53,4 +53,4 @@ def generate_caption_for_image(image): # image = Image.open(image_path) photo = extract_features(image, xception_model) caption = generate_caption(model, tokenizer, photo, max_length) - return caption, image + return caption diff --git a/MasterProject/homeapp/views.py b/MasterProject/homeapp/views.py index 8ebd9ac..83762a0 100644 --- a/MasterProject/homeapp/views.py +++ b/MasterProject/homeapp/views.py @@ -34,14 +34,18 @@ def upload_image_view(request): # Captioning Function calls START here: - captions, _ = generate_caption_for_image(image) + captions = generate_caption_for_image(image) # Captioning function calls END here - # ocrText = perform_ocr(image) + ocrText = perform_ocr(image) + if (ocrText == ""): + ocrText = "No Text Found" + + contcatenated = "Visual Elocution: " + captions + "\n" + "OCR: " + ocrText # return a response if needed - return JsonResponse({'status': 'success', 'message': captions}) + return JsonResponse({'status': 'success', 'message': contcatenated}) # return JsonResponse({'status': 'success', 'message': ocrText, 'captions': captions}) return JsonResponse({'status': 'error', 'message': 'Invalid request method'})