Spaces:
Sleeping
Sleeping
input shape
Browse files
app.py
CHANGED
@@ -183,16 +183,16 @@ def encrypt(user_id, input_image):
|
|
183 |
raise gr.Error("Please choose an image first.")
|
184 |
|
185 |
# Resize the image if it hasn't the shape (224, 224, 3)
|
186 |
-
if input_image.shape != (
|
187 |
input_image_pil = Image.fromarray(input_image)
|
188 |
-
input_image_pil = input_image_pil.resize((
|
189 |
input_image = numpy.array(input_image_pil)
|
190 |
|
191 |
# Convert RGB to grayscale
|
192 |
input_image_gray = numpy.mean(input_image, axis=2).astype(numpy.uint8)
|
193 |
|
194 |
# Reshape to (1, 1, 224, 224)
|
195 |
-
input_image_reshaped = input_image_gray.reshape(1, 1,
|
196 |
|
197 |
# Convert to int12 (assuming the range is 0-255, we can simply cast to int16)
|
198 |
input_image_int12 = input_image_reshaped.astype(numpy.int16)
|
@@ -364,7 +364,7 @@ with demo:
|
|
364 |
gr.Markdown("## Client side")
|
365 |
gr.Markdown("### Step 1: Upload an EEG image. ")
|
366 |
gr.Markdown(
|
367 |
-
f"The image will automatically be resized to shape (
|
368 |
"The image here, however, is displayed in its original resolution."
|
369 |
)
|
370 |
with gr.Row():
|
|
|
183 |
raise gr.Error("Please choose an image first.")
|
184 |
|
185 |
# Resize the image if it hasn't the shape (224, 224, 3)
|
186 |
+
if input_image.shape != (32, 32, 3):
|
187 |
input_image_pil = Image.fromarray(input_image)
|
188 |
+
input_image_pil = input_image_pil.resize((32, 32))
|
189 |
input_image = numpy.array(input_image_pil)
|
190 |
|
191 |
# Convert RGB to grayscale
|
192 |
input_image_gray = numpy.mean(input_image, axis=2).astype(numpy.uint8)
|
193 |
|
194 |
# Reshape to (1, 1, 224, 224)
|
195 |
+
input_image_reshaped = input_image_gray.reshape(1, 1, 32, 32)
|
196 |
|
197 |
# Convert to int12 (assuming the range is 0-255, we can simply cast to int16)
|
198 |
input_image_int12 = input_image_reshaped.astype(numpy.int16)
|
|
|
364 |
gr.Markdown("## Client side")
|
365 |
gr.Markdown("### Step 1: Upload an EEG image. ")
|
366 |
gr.Markdown(
|
367 |
+
f"The image will automatically be resized to shape (32x32). "
|
368 |
"The image here, however, is displayed in its original resolution."
|
369 |
)
|
370 |
with gr.Row():
|
common.py
CHANGED
@@ -20,7 +20,7 @@ CLIENT_TMP_PATH.mkdir(exist_ok=True)
|
|
20 |
SERVER_TMP_PATH.mkdir(exist_ok=True)
|
21 |
|
22 |
# The input images' shape. Images with different input shapes will be cropped and resized by Gradio
|
23 |
-
INPUT_SHAPE = (
|
24 |
|
25 |
# Retrieve the input examples directory
|
26 |
INPUT_EXAMPLES_DIR = REPO_DIR / "input_examples"
|
|
|
20 |
SERVER_TMP_PATH.mkdir(exist_ok=True)
|
21 |
|
22 |
# The input images' shape. Images with different input shapes will be cropped and resized by Gradio
|
23 |
+
INPUT_SHAPE = (1, 1, 32, 32)
|
24 |
|
25 |
# Retrieve the input examples directory
|
26 |
INPUT_EXAMPLES_DIR = REPO_DIR / "input_examples"
|