File size: 3,429 Bytes
fbe10b6
 
274099f
 
 
 
 
 
 
 
 
 
ad12f54
9da470d
fbe10b6
 
ec17209
fbe10b6
1d47717
 
d67e1fb
fbe10b6
ec17209
 
 
 
 
 
fbe10b6
ec17209
fbe10b6
ec17209
fbe10b6
ec17209
 
 
 
fbe10b6
ec17209
 
 
 
fbe10b6
7b286c1
 
fbe10b6
ec17209
 
fbe10b6
ec17209
 
 
44ed0c1
 
 
a35795b
 
3731633
a35795b
3731633
a35795b
 
 
3731633
a35795b
 
ad12f54
 
3731633
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad12f54
 
 
cb27103
 
 
 
 
 
dbd9b26
 
 
 
 
 
 
 
9da470d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
library_name: diffusers
datasets:
- NNNan/UniEM-3M
base_model:
- stabilityai/stable-diffusion-xl-base-1.0
pipeline_tag: text-to-image
tags:
- materials
- microstructure
- electron_micrograph
- characterization
- scientific_figure_understanding
license: mit
---

# UniEM-Gen

## πŸ–ΌοΈ Example Outputs  

![Generated Example](examples/figure1.png)

## πŸ“˜ Model Summary  
This is the text-to-image diffusion model trained on the complete **[UniEM-3M](https://huggingface.co/datasets/NNNan/UniEM-3M)** dataset.  
It is designed for **electron microscopy (EM)-style image generation**, enabling:  
- Scientific data augmentation  
- Proxy generation for microstructural distributions  
- Multimodal research in materials science

---

## πŸš€ Usage Example  

### Using `diffusers`
```python
from diffusers import StableDiffusionPipeline
import torch

# Load model from Hugging Face
model_id = "NNNan/UniEM-Gen"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

# Example prompt, sampled from UniEM-3M.
prompt = "SEM of Ceramic Powder: A mix of plate-like and rod-shaped particles. nanostructured. high density. densely packed and agglomerated. Multilayer. Wide range of particle sizes. Grayscale particles on a dark background."

# Generate image
image = pipe(prompt).images[0]

# Save or display
image.save("generated_em.png")
image.show()
```
---

### πŸ”„ Flexible Prompt Composition

You can generate structured scientific descriptions by randomly sampling one term from each of the nine attribute categories defined in the **[UniEM-3M](https://huggingface.co/datasets/NNNan/UniEM-3M)**. This repository includes attribute_values.json, which contains all observed values for these attributes, enabling reproducible and diverse prompt generation.

Use the following template to assemble the sampled terms into a coherent description:

```text
<microscopy_type> of <subject>: <morphology>. <surface_texture>. <particle_density>. <distribution>. <layering>. <pixel_size_profile>. <color_profile>.
"πŸ’¬ Replace each <...> placeholder with a real value from the corresponding category."
```

```python
# Sampled attributes from UniEM-3M
from huggingface_hub import hf_hub_download
import json
import random

# Download the attribute_values.json file from the repo
json_path = hf_hub_download(
    repo_id="NNNan/UniEM-Gen",
    filename="attribute_values.json"
)

# Load the attribute values
with open(json_path, "r", encoding="utf-8") as f:
    attribute_values = json.load(f)

# Generate a random description
template = "{microscopy_type} of {subject}: {morphology}. {surface_texture}. {particle_density}. {distribution}. {layering}. {pixel_size_profile}. {color_profile}."
sampled = {k: random.choice(list(v)) for k, v in attribute_values.items()}
prompt = template.format(**sampled)
print(prompt)
```

---

## πŸ“– Citation  
If you use this dataset, please cite:  

```bibtex
@misc{wang2025uniem3muniversalelectronmicrograph,
      title={UniEM-3M: A Universal Electron Micrograph Dataset for Microstructural Segmentation and Generation}, 
      author={Nan wang and Zhiyi Xia and Yiming Li and Shi Tang and Zuxin Fan and Xi Fang and Haoyi Tao and Xiaochen Cai and Guolin Ke and Linfeng Zhang and Yanhui Hong},
      year={2025},
      eprint={2508.16239},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2508.16239}, 
}