Jangai commited on
Commit
223a025
·
verified ·
1 Parent(s): 40c9bf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -16,15 +16,15 @@ model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-large-handwri
16
  def display_sketch(sketch):
17
  logging.debug(f"Received sketch data: {sketch}")
18
 
19
- if isinstance(sketch, np.ndarray):
20
- image_data = sketch
21
  logging.debug(f"Image data type: {type(image_data)}")
22
- logging.debug(f"Image data shape: {np.array(image_data).shape}")
23
 
24
- plt.imshow(image_data, cmap='gray')
25
  plt.axis('off')
26
 
27
- with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_file:
28
  plt.savefig(temp_file.name, bbox_inches='tight', pad_inches=0)
29
  temp_file_path = temp_file.name
30
 
 
16
  def display_sketch(sketch):
17
  logging.debug(f"Received sketch data: {sketch}")
18
 
19
+ if isinstance(sketch, dict) and 'composite' in sketch:
20
+ image_data = np.array(sketch['composite'], dtype=np.uint8)
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
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".png", dir="/mnt/data") as temp_file:
28
  plt.savefig(temp_file.name, bbox_inches='tight', pad_inches=0)
29
  temp_file_path = temp_file.name
30