# AI use cases for Fle Xray (VictorButoi/FleXray)

Repo: [VictorButoi/FleXray](https://github.com/VictorButoi/FleXray) | Use cases: 4 | Page: https://dedupedai.com/use-cases/victorbutoi-flexray/

FleXray is a Python command-line tool and package that segments anatomy in X-ray images and can also train new full-body X-ray segmentation models.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Segment X-ray images into anatomy masks from the terminal: https://dedupedai.com/use-cases/victorbutoi-flexray/segment-xray-images-from-the-command-line/
- Raise mask quality with the five-model ensemble: https://dedupedai.com/use-cases/victorbutoi-flexray/get-higher-quality-masks-with-ensemble-and-tta/
- Ask Claude Code to segment X-rays through Fle Xray MCP: https://dedupedai.com/use-cases/victorbutoi-flexray/segment-xrays-from-claude-code-with-mcp/
- Fine-tune Fle Xray onto your own X-ray label set: https://dedupedai.com/use-cases/victorbutoi-flexray/fine-tune-flexray-onto-a-custom-label-protocol/

## How to segment X-ray images into anatomy masks from the terminal with Fle Xray

Repo: [VictorButoi/FleXray](https://github.com/VictorButoi/FleXray) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Run flexify on one image or a folder and get NumPy mask, probability, and logit arrays.

**Who it is for:** A medical imaging researcher or data engineer who has a set of X-ray images and needs anatomy masks without writing model code.

**The problem:** Manually outlining anatomy on many X-rays is slow, and many segmentation tools need model setup before any output appears.

**The outcome:** A predictions folder containing image_masks.npy, image_probabilities.npy, image_logits.npy, and label_names.json for each input.

### Steps

1. Install the package with `python -m pip install flexray`.
2. Run a single prediction with `flexify --input ./image.png --output-dir ./predictions`.
3. To predict a whole folder, pass the folder to the same command with `flexify --input ./xrays --output-dir ./predictions`. (inferred, check the README)
4. Open label_names.json to map channel numbers to anatomical labels, then load the .npy files with NumPy.

### Prompt to paste into your agent

```text
In the FleXray repo (pip package flexray), run `flexify --input <input-path> --output-dir <output-dir>` on the target X-ray image or folder. Expect image_masks.npy, image_probabilities.npy, image_logits.npy, and label_names.json per image. Verify that the masks arrays are CxHxW with C equal to the number of labels in label_names.json.
```

### Caveat

The README describes segmentation output but does not state clinical validation, so treat masks as research output unless you verify them yourself.

Risk, credentials: The first run downloads weights from Hugging Face, so a token may be needed if access to the repository is restricted in your environment.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/victorbutoi-flexray/segment-xray-images-from-the-command-line/

## How to raise mask quality with the five-model ensemble with Fle Xray

Repo: [VictorButoi/FleXray](https://github.com/VictorButoi/FleXray) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Use --ensemble and --tta-samples to trade run time for more accurate anatomy masks.

**Who it is for:** A researcher comparing segmentation results who needs the best available output for a small batch of X-rays and can wait longer per image.

**The problem:** A single forward pass of the flagship model may not give the most reliable masks for difficult images.

**The outcome:** Masks from the X-High setting, five-model ensemble with 8-pass test-time augmentation, saved to a predictions folder, optionally limited to one label.

### Steps

1. Install the package with `python -m pip install flexray`.
2. Run the X-High mode with `flexify --ensemble --tta-samples 8 --input ./image.png --output-dir ./predictions`.
3. To keep one anatomical label only, add `--binary femurs` to the same command.
4. Compare the output against the Low mode with `flexify --input ./image.png --output-dir ./predictions_low` and review the masks side by side. (inferred, check the README)

### Prompt to paste into your agent

```text
In the FleXray repo, run `flexify --ensemble --tta-samples 8 --input <image-path> --output-dir <output-dir>` on the target X-ray. Expect the same three .npy arrays plus label_names.json. Verify that the mask arrays are uint8 and that the channel count matches label_names.json.
```

### Caveat

The README does not give run-time or accuracy numbers for the modes, so the time cost and quality gain must be measured on your own images.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/victorbutoi-flexray/get-higher-quality-masks-with-ensemble-and-tta/

## How to ask Claude Code to segment X-rays through Fle Xray MCP with Fle Xray

Repo: [VictorButoi/FleXray](https://github.com/VictorButoi/FleXray) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Register the fxr-mcp server so an AI client can run segment_image and inspect label protocols.

**Who it is for:** A developer or analyst who already works in Claude Code or Claude Desktop and wants to run X-ray segmentation through natural language.

**The problem:** Switching between a chat assistant and a terminal to run segmentation and read results slows down analysis of a batch of images.

**The outcome:** An AI client that calls segment_image on a named X-ray and reports per-label statistics, plus lookups of available models and protocols.

### Steps

1. Install the MCP extra with `python -m pip install "flexray[mcp]"`.
2. Register the server with `claude mcp add flexray -- fxr-mcp`.
3. Start Claude Code and ask it to use the flexray tools on your image path.
4. Check that the reply includes per-label statistics from segment_image, then open the saved output files to confirm them.

### Prompt to paste into your agent

```text
Using the FleXray MCP server from the FleXray repo, call segment_image on <image-path> and report the per-label statistics. Expect a summary of each anatomical label and the output files. Verify the label names match the label_names.json written by the run.
```

### Caveat

The README names the MCP tools but does not list their parameters, so check docs/mcp.md before scripting calls beyond the natural-language use shown.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/victorbutoi-flexray/segment-xrays-from-claude-code-with-mcp/

## How to fine-tune Fle Xray onto your own X-ray label set with Fle Xray

Repo: [VictorButoi/FleXray](https://github.com/VictorButoi/FleXray) | Difficulty: Advanced | Time: 3 hours | Basis: From the README

Map your masks to the Fle Xray protocol, pack the data, and train from the released weights.

**Who it is for:** An ML engineer at a research group with labeled X-ray masks that use a different set of anatomical labels than the released model.

**The problem:** The released model predicts its own label protocol, so a custom label set needs a training path that starts from the existing weights.

**The outcome:** A fine-tuned run that starts from VictorButoi/flexray with a replaced head, checked first with a CPU dry run on the packaged example.

### Steps

1. Install the training extra with `python -m pip install "flexray[train]"`.
2. Scaffold a dataset spec with `fxr-dataset scaffold xray-seg --images ./images --masks ./masks --name MyXrays --output dataset.yml`.
3. Compile the label mapping with `fxr-protocol compile --dataset CustomHips.yml`, then pack the data with `fxr-dataset pack dataset.yml /data/MyXrays`.
4. Dry-run training on CPU with `fxr-train train_custom.yml --set log.root="$PWD/work/runs" --device cpu --dry-run --smoke-data` before a real run, and add `--init-from VictorButoi/flexray --replace-head` to start from the released weights. (inferred, check the README)

### Prompt to paste into your agent

```text
In the FleXray repo, scaffold a dataset from <images-dir> and <masks-dir> with fxr-dataset, then dry-run fxr-train on CPU with --init-from VictorButoi/flexray --replace-head. Expect a dry run that completes without error and a packed ThunderDB dataset. Verify that the label mapping in the compiled protocol covers every mask id in your data.
```

### Caveat

The released weights are under CC-BY-NC-4.0 unless a model card says otherwise, so a fine-tuned model may carry the same non-commercial limit.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/victorbutoi-flexray/fine-tune-flexray-onto-a-custom-label-protocol/
