-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
39 lines (31 loc) · 1.46 KB
/
Copy pathexample.py
File metadata and controls
39 lines (31 loc) · 1.46 KB
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
#!/usr/bin/env python3
"""Example script demonstrating programmatic usage of barkprints."""
from barkprints.text_generator import TextGenerator
def main():
# Create a generator instance
generator = TextGenerator()
# Generate text from a bark image using nature corpus
print("=== Nature Voice ===")
nature_text = generator.generate("barks.jpg", "nature")
print(nature_text)
# Try with literature corpus
print("\n=== Literature Voice ===")
lit_text = generator.generate("barks.jpg", "literature")
print(lit_text)
# Adjust alpha: more coherent (0.2) vs more bark-driven (0.8)
print("\n=== Alpha Variations ===")
gen_coherent = TextGenerator(alpha=0.2)
gen_bark = TextGenerator(alpha=0.8)
print(f"Coherent (alpha=0.2): {gen_coherent.generate('barks.jpg', 'nature')}")
print(f"Bark-driven (alpha=0.8): {gen_bark.generate('barks.jpg', 'nature')}")
# The same image always produces the same output (deterministic)
print("\n=== Verifying Determinism ===")
nature_text2 = generator.generate("barks.jpg", "nature")
print(f"Outputs are identical: {nature_text == nature_text2}")
# Show how different corpora give different "voices" to the same bark
print("\n=== Same Bark, Different Perspectives ===")
print(f"Nature voice: {nature_text}")
print(f"Literary voice: {lit_text}")
print("\nThe bark's features steer a walk through each corpus's word space!")
if __name__ == "__main__":
main()