Update README.md
Browse files
README.md
CHANGED
@@ -52,30 +52,35 @@ image.show()
|
|
52 |
|
53 |
### 🔄 Flexible Prompt Composition
|
54 |
|
55 |
-
|
56 |
|
57 |
-
|
58 |
|
59 |
```text
|
60 |
<microscopy_type> of <subject>: <morphology>. <surface_texture>. <particle_density>. <distribution>. <layering>. <pixel_size_profile>. <color_profile>.
|
61 |
-
💬 Replace each <...> placeholder with a real value from the corresponding category.
|
62 |
```
|
63 |
|
64 |
```python
|
65 |
# Sampled attributes from UniEM-3M
|
66 |
-
from
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
79 |
print(prompt)
|
80 |
```
|
81 |
|
|
|
52 |
|
53 |
### 🔄 Flexible Prompt Composition
|
54 |
|
55 |
+
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.
|
56 |
|
57 |
+
Use the following template to assemble the sampled terms into a coherent description:
|
58 |
|
59 |
```text
|
60 |
<microscopy_type> of <subject>: <morphology>. <surface_texture>. <particle_density>. <distribution>. <layering>. <pixel_size_profile>. <color_profile>.
|
61 |
+
"💬 Replace each <...> placeholder with a real value from the corresponding category."
|
62 |
```
|
63 |
|
64 |
```python
|
65 |
# Sampled attributes from UniEM-3M
|
66 |
+
from huggingface_hub import hf_hub_download
|
67 |
+
import json
|
68 |
+
import random
|
69 |
+
|
70 |
+
# Download the attribute_values.json file from the repo
|
71 |
+
json_path = hf_hub_download(
|
72 |
+
repo_id="NNNan/UniEM-Gen",
|
73 |
+
filename="attribute_values.json"
|
74 |
+
)
|
75 |
+
|
76 |
+
# Load the attribute values
|
77 |
+
with open(json_path, "r", encoding="utf-8") as f:
|
78 |
+
attribute_values = json.load(f)
|
79 |
+
|
80 |
+
# Generate a random description
|
81 |
+
template = "{microscopy_type} of {subject}: {morphology}. {surface_texture}. {particle_density}. {distribution}. {layering}. {pixel_size_profile}. {color_profile}."
|
82 |
+
sampled = {k: random.choice(list(v)) for k, v in attribute_values.items()}
|
83 |
+
prompt = template.format(**sampled)
|
84 |
print(prompt)
|
85 |
```
|
86 |
|