Skip to content

Repository files navigation

title Zebrafish Segmentation Web App
emoji 🐟
colorFrom blue
colorTo green
sdk gradio
sdk_version 6.3.0
app_file app.py
pinned false

🐟 Zebrafish Segmentation Web App

Open in Spaces

Table of Contents

How to use the Zebrafish Segmentation Web App

Selecting a Model

Before you begin, you can select the model that will analyze the images. The General Model is trained on a broad dataset. You can choose between a faster model and a more accurate model. Below, you can expand the list of additional models that have been trained and optimized for specific types of photos.

Model selection option

Uploading Images

You can upload images of the zebrafish in two ways:

Method 1: Upload a Folder

You can upload an entire folder containing zebrafish images.

Upload folder option

Select the folder of your choosing from the file dialog:

Select folder

Then click "Upload" to upload the folder. You'll need to confirm the upload by clicking "Upload" again:

Confirm upload

Wait for the images to load and appear:

Images loaded

Method 2: Upload Individual Images

Alternatively, you can upload individual images one by one.

Upload individual images option

Select the images of your choosing and click "Open" to upload them:

Select individual images

Wait for the images to load and appear:

Images loaded

Scale Bar Calibration

Once the images are successfully uploaded, the first one will appear on the screen. The scale bar will be automatically detected and the number of pixels it spans will be displayed.

Scale Bar Automatic Detection

Enter the physical length printed above the bar (e.g. 500) and its unit, then click Apply to compute the µm/px calibration. The image width/height fields below will be filled automatically.

Length Values

If automatic detection has incorrectly identified the scale bar, you can use the Manual Scale Bar Entry option below. The image loads automatically below. Click on it to mark the two endpoints of the scale bar line:

  • 1st click → START (one end, shown in green)
  • 2nd click → END (other end, shown in red)

Manual Scale Bar Entry

After both endpoints are set, enter the physical length below and click Apply Manual Points to fill in the calibration automatically.

Apply Manual Points

You can also skip this step and enter the distances manually.

Selecting Endpoints

After uploading your images, choose which endpoints you want to analyze:

Select endpoints

You can select:

  • Length: Measure the length of the zebrafish (centerline path length in µm)
  • Curvature: Classify the zebrafish into curvature classes (1-4)
    • Class 1: Most severe curvature
    • Class 2: Moderate-severe curvature
    • Class 3: Mild curvature
    • Class 4: Most healthy (minimal curvature)
  • Length/Straight Line Ratio: The ratio between the actual centerline length and the straight-line distance between endpoints. A value close to 1.0 indicates a nearly straight fish, while higher values indicate more curvature. This metric quantifies body curvature independently of fish size.
  • Eye Size: Calculates the eye area in µm² and measures the eye diameter in µm.
  • Edema: Calculates the edema area in µm² .
  • Swim Bladder: Calculates the swim bladder area in µm² .

Run

To start the processing, click the Run button.

Run

Boxplots

After processing, you'll see boxplots visualizing the distribution of the selected endpoints. These boxplots are also included in the Excel file:

Boxplots

The boxplots display:

  • Fish Lengths: Distribution of measured centerline lengths in µm
  • Curvatures: Distribution of curvature classifications (1-4)
  • Length/Straight Line Ratio: Distribution of the length ratio metric, where values closer to 1.0 indicate straighter fish
  • Eye Area: Distribution of calculated eye areas in µm²
  • Edema Area: Distribution of calculated edema areas in µm²
  • Swim Bladder: Distribution of calculated swim bladder areas in µm²

The ratio visualization helps identify fish with significant body curvature. You can see in the example image that some fish have ratios above 1.0, indicating curved body shapes:

Length/Straight Line Ratio explanation

The cyan line shows the straight-line distance between endpoints, while the actual centerline path (shown in red) is longer due to body curvature. The ratio quantifies this difference.

Segmentation Preview

A gallery displays segmentation overlays for the uploaded images (thumbnails include a short filename label).

Segmentation preview

If automatic detection fails use Manual Point Adjustment tool to manually set head and tail points.

  • Click an image in the gallery above to select it for manual editing
  • Click on the large image below to set the HEAD (green, 1st click) and TAIL (red, last click) points
  • Optionally click additional midway points between HEAD and TAIL (yellow) to force the path through them
  • Click 'Apply Manual Points' to recalculate the length

Manual points

If you want to correct an incorrect segmentation by yourself, use the Manual Mask Editor tool. After selecting the required image from the gallery at the top, choose the appropriate layer: body, eye, or edema, and click Load Image into Editor.

Mask Editor

The tool selection is located on the left. To draw in missing fragments, select the brush tool and the yellow color. To remove excess parts, paint over them with blue. The eraser tool is used to erase the strokes you just drew.

Mask Editor Tools

You can also adjust the size of the selected tool by clicking the button at the bottom of the toolbar.

Mask Editor Tools Size

To erase everything you’ve drawn, click the Reset button. To apply the changes, click Apply. After that, the canvas will be cleared, and the updated image will appear in the gallery at the top.

Generating a Final Excel

First, select the desired image from the preview at the top, and then click the checkboxes next to the endpoints you want to exclude from the final statistics. Then press the Save Exclusions for This Image button (the row will still appear but the cell will say Excluded and it won't count toward statistics).

Exclude Measurements for This Image

In the field below, you can enter sheet name that will be generated.

Sheet name

When you're ready, press the Generate Final Excel button. If the download does not start automatically, click the button again.

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages