Jangai commited on
Commit
2f5a61a
·
verified ·
1 Parent(s): 47c05d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -21,11 +21,11 @@ def display_sketch(sketch):
21
  logging.debug(f"Image data type: {type(image_data)}")
22
  logging.debug(f"Image data shape: {image_data.shape}")
23
 
24
- plt.imshow(image_data)
25
- plt.axis('off')
26
 
27
  temp_file_path = os.path.join(os.getcwd(), "output.png")
28
- plt.savefig(temp_file_path, bbox_inches='tight', pad_inches=0)
29
  logging.debug(f"Image saved to: {temp_file_path}")
30
 
31
  return temp_file_path
@@ -43,6 +43,7 @@ def recognize_text(image_path):
43
  # Generate the text
44
  generated_ids = model.generate(pixel_values)
45
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
 
46
  return generated_text
47
  except Exception as e:
48
  logging.error(f"Error in recognizing text: {e}")
 
21
  logging.debug(f"Image data type: {type(image_data)}")
22
  logging.debug(f"Image data shape: {image_data.shape}")
23
 
24
+ # Ensure the image is in the correct format
25
+ image = Image.fromarray(image_data, 'RGBA').convert('RGB')
26
 
27
  temp_file_path = os.path.join(os.getcwd(), "output.png")
28
+ image.save(temp_file_path)
29
  logging.debug(f"Image saved to: {temp_file_path}")
30
 
31
  return temp_file_path
 
43
  # Generate the text
44
  generated_ids = model.generate(pixel_values)
45
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
46
+ logging.debug(f"Recognized text: {generated_text}")
47
  return generated_text
48
  except Exception as e:
49
  logging.error(f"Error in recognizing text: {e}")