Thomas Chardonnens commited on
Commit ·
f55a150
1
Parent(s): 47fc2ef
fix image processing
Browse files146 unmodified lines147148149150151152153150151152153154155156157158159160161162163164146 unmodified lines if input_image is None: raise gr.Error("Please choose an image first.")
if input_image.shape[-1] != 3: raise ValueError(f"Input image must have 3 channels (RGB). Current shape: {input_image.shape}")
# Resize the image if it hasn't the shape (224, 224, 3) if input_image.shape != (224, 224, 3): input_image_pil = Image.fromarray(input_image) input_image_pil = input_image_pil.resize((224, 224)) input_image = numpy.array(input_image_pil)
# Convert to grayscale and reshape to (1, 1, 224, 224) input_image = numpy.mean(input_image, axis=2).astype(numpy.int32) input_image = input_image.reshape(1, 1, 224, 224)
# Scale values to 12-bit range (0-4095) input_image = (input_image / 255.0 * 4095).astype(numpy.int32)
# Retrieve the client API client = get_client(user_id)
app.py+7-4