From 37f446e77f77894ad0de74e967558103223ee027 Mon Sep 17 00:00:00 2001 From: doge Date: Sat, 6 Jan 2024 12:36:48 +0000 Subject: [PATCH] added stability support --- miner/miner.py | 64 ++++++---- state.json | 2 +- template/protocol.py | 60 ++++++--- template/reward.py | 18 ++- template/utils.py | 46 ++++++- test_scripts/compare_stability.py | 45 +++++++ test_scripts/test_stability.py | 82 ++++++++---- validators/base_validator.py | 2 + validators/image_validator.py | 201 +++++++++++++++++------------- validators/text_validator.py | 4 +- validators/weight_setter.py | 2 +- 11 files changed, 359 insertions(+), 167 deletions(-) create mode 100644 test_scripts/compare_stability.py diff --git a/miner/miner.py b/miner/miner.py index 220ba620..b381636f 100644 --- a/miner/miner.py +++ b/miner/miner.py @@ -5,21 +5,28 @@ import copy import json import os +import io +import base64 import boto3 import pathlib import threading import time +import requests import traceback +import requests import anthropic from abc import ABC, abstractmethod from collections import deque from functools import partial from typing import Tuple +from stability_sdk import client import bittensor as bt import wandb from config import check_config, get_config from openai import AsyncOpenAI, OpenAI +from PIL import Image +import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation from anthropic_bedrock import AsyncAnthropicBedrock, HUMAN_PROMPT, AI_PROMPT, AnthropicBedrock import template @@ -34,6 +41,12 @@ if not OpenAI.api_key: raise ValueError("Please set the OPENAI_API_KEY environment variable.") +stability_api = client.StabilityInference( + key=os.environ['STABILITY_KEY'], + verbose=True, + engine="stable-diffusion-xl-1024-v1-0" +) + api_key = os.environ.get("ANTHROPIC_API_KEY") bedrock_client = AsyncAnthropicBedrock( @@ -392,14 +405,19 @@ async def images(self, synapse: ImageResponse) -> ImageResponse: model = synapse.model messages = synapse.messages size = synapse.size - width, height = self.size.split('x') - width = int(width) - height = int(height) + width = synapse.width + height = synapse.height quality = synapse.quality style = synapse.style seed = synapse.seed steps = synapse.steps image_revised_prompt = None + cfg_scale = synapse.cfg_scale + sampler = synapse.sampler + samples = synapse.samples + image_data = {} + + bt.logging.debug(f"data = {provider, model, messages, size, width, height, quality, style, seed, steps, image_revised_prompt, cfg_scale, sampler, samples}") if provider == "OpenAI": meta = await client.images.generate( @@ -411,44 +429,36 @@ async def images(self, synapse: ImageResponse) -> ImageResponse: ) image_url = meta.data[0].url image_revised_prompt = meta.data[0].revised_prompt + image_data["url"] = image_url + image_data["image_revised_prompt"] = image_revised_prompt + bt.logging.info(f"returning image response of {image_url}") elif provider == "Stability": + bt.logging.debug(f"calling stability for {messages, seed, steps, cfg_scale, width, height, samples, sampler}") + meta = stability_api.generate( prompt=messages, - seed=steps, + seed=seed, steps=steps, - cfg_scale=8.0, + cfg_scale=cfg_scale, width=width, height=height, - samples=1, - sampler=generation.SAMPLER_K_DPMPP_2M, + samples=samples, + # sampler=sampler ) # Process and upload the image - for artifact in meta.artifacts: - if artifact.finish_reason == generation.FILTER: - bt.logging.error("Safety filters activated, prompt could not be processed.") - elif artifact.type == generation.ARTIFACT_IMAGE: - img = Image.open(io.BytesIO(artifact.binary)) - img_buffer = io.BytesIO() - img.save(img_buffer, format="PNG") - img_buffer.seek(0) - # Upload to file.io - response = requests.post('https://file.io', files={'file': img_buffer}) - if response.status_code == 200: - image_url = response.json()['link'] - else: - raise Exception("Failed to upload the image.") + b64s = [] + for image in meta: + for artifact in image.artifacts: + b64s.append(base64.b64encode(artifact.binary).decode()) + + image_data["b64s"] = b64s + bt.logging.info(f"returning image response to {messages}") else: bt.logging.error(f"Unknown provider: {provider}") - image_data = { - "url": image_url, - "revised_prompt": image_revised_prompt, - } - synapse.completion = image_data - bt.logging.info(f"returning image response of {synapse.completion}") return synapse except Exception as exc: diff --git a/state.json b/state.json index 33c6d4c1..3190f351 100644 --- a/state.json +++ b/state.json @@ -1 +1 @@ -{"text": {"themes": ["Philosopy", "Technology", "Physics", "Ethics", "Academic Writing", "Economy", "History", "Medicine", "Toxicity", "Roleplay", "Entertainment", "Biology", "Counterfactual", "Literature", "Chemistry", "Writing", "Sport", "Law", "Language", "Computer Science", "Multilangual", "Common Sense", "Art", "Complex FormatCode Generation", "Math", "Code Debug", "Reasoning", "Global Cultures and Societies", "Modern and Ancient Civilizations", "Innovations in Science and Technology", "Environmental Conservation and Biodiversity", "World Religions and Philosophical Thought", "Global Economy and International Trade", "Public Health and Pandemic Response", "Human Rights and Social Justice Issues", "Political Systems and International Relations", "Major Historical Events and their Impact", "Advancements in Medicine and Healthcare", "Fundamentals of Physics and the Cosmos", "Cognitive Development and Learning Theories", "Sustainable Development and Green Technologies", "Media Literacy and News Analysis", "Classical and Modern Literature", "Fundamentals of Mathematics and Logic"], "questions": ["Explain the concept of comparative advantage in international trade.", "Discuss the impact of tariffs on global trade and the economy.", "Examine the role of multinational corporations in the global economy.", "Describe the benefits and challenges of free trade agreements.", "Analyze the effects of currency exchange rates on international trade.", "Discuss the importance of the World Trade Organization (WTO) in promoting global trade.", "Explain the concept of balance of payments and its significance in the global economy.", "Discuss the impact of economic sanctions on international trade.", "Examine the role of intellectual property rights in global trade.", "Describe the factors that contribute to income inequality in the global economy.", "What are the key drivers of global economic growth?", "Explain the concept of comparative advantage in international trade.", "How do tariffs affect international trade and global economic stability?", "Discuss the role of multinational corporations in the global economy.", "What are the main challenges faced by developing countries in participating in international trade?", "Explain the concept and impact of foreign direct investment on the global economy.", "What are the major components of a country's balance of payments?", "Discuss the pros and cons of free trade agreements in the context of the global economy.", "How does currency exchange rate fluctuation impact international trade?", "What are the potential consequences of trade protectionism on the global economy?", "Explain the concept of comparative advantage and its role in international trade.", "Discuss the impact of tariffs on a country's economy and international trade.", "Analyze the benefits and drawbacks of participating in a regional trade agreement.", "Examine the role of multinational corporations in shaping the global economy.", "Evaluate the significance of foreign direct investment (FDI) in driving economic growth.", "Explain the concept of exchange rates and how they affect international trade.", "Discuss the challenges and opportunities of global supply chains in the context of international trade.", "Analyze the role of international financial institutions, such as the World Bank and IMF, in supporting global economic stability.", "Examine the impact of globalization on income inequality within and between countries.", "Discuss the potential consequences of trade wars on the global economy.", "What are the main drivers of global economic growth?", "How does international trade contribute to economic development?", "What are the advantages and disadvantages of free trade?", "Explain the concept of comparative advantage and its impact on international trade.", "What are the major challenges faced by developing countries in participating in international trade?", "What role does the World Trade Organization (WTO) play in facilitating global trade?", "Discuss the impact of tariffs on international trade and the global economy.", "Explain the concept of foreign direct investment (FDI) and its significance in the global economy.", "How do exchange rates affect international trade and the competitiveness of nations?", "What are the potential benefits and risks of regional economic integration?", "What are the main factors that influence global economic growth?"], "theme_counter": 0, "question_counter": 0}, "images": {"themes": ["The Inner Journey", "The Dance of Life", "Enigmatic Reflections", "The Poetry of Silence", "Melodies of the Mind", "Whimsical Enigmas", "Whispers of Inspiration", "Colorful Abstractions", "Dancing Colors", "Transcendent moments", "The Essence of Light", "Metamorphosis", "Duality in Nature", "Transcending Time", "Essence of Life", "Ethereal Abstractions", "Hidden Depths", "Urban Rhythms", "Inner emotions", "Whispers of the Night", "Dreams that Soar", "Enchanted Melodies", "Embracing Solitude", "Dreamlike Reflections", "Abstracted Memories", "Melodies of the Mind", "Evolving Realities", "Serenade of Seasons", "Serenity in chaos", "Interwoven Narratives", "Cosmic Connections", "Interplay of elements", "Immersive Portals", "Whispers of the Wind", "Whispered Whimsies", "Painted Passions", "Celestial Strokes", "Imaginary Journeys", "Hidden Treasures", "Shimmering Illusions", "The Strength Within", "Evolving Patterns", "Exploring the Subconscious", "Harmony in Diversity", "Cosmic Dreams", "The Fragile Balance", "Mystical Wanderlust", "Ephemeral Moments", "Whispered Visions", "Metamorphosis of Form", "Capturing Times Essence", "Cascading Emotions", "Whispers of the heart", "Chasing Illusions", "The Fluidity of Form", "Emerging Horizons", "Unveiled Whispers", "Celestial Beings", "... (68 KB left)", "Journey of the Soul", "Transcendent Transparencies", "Tranquil Transcendence", "Luminous Visions", "Sensory Overload", "Exploring identity", "Vibrant Chaos", "The fragility of life", "Eternal Echoes", "Whispers of Wonder", "Whimsical Delights", "Strokes of Serenity", "Rhythm of Colors", "The Art of Silence", "Serenade of Shadows", "Imaginary Landscapes", "Dreams and reality", "Abstract Realities", "Untamed Imagination", "Embracing vulnerability", "Dreamlike Visions", "Melodies of Nature", "Hidden Symmetry", "Mystic Mosaic", "Symphony of Life", "The Art of Transformation", "Reimagining Classics", "Ephemeral beauty", "The Spirit of Movement", "Fragments of Time", "The Beauty of Decay", "The Magic of Childhood", "The Essence of Stillness", "Abstract Energy", "Whirling Vortex", "Parallel Universes Collide", "Whirling Dervish", "Enigmatic Beauty", "The Art of Balance", "Merging Dimensions", "Celestial Rhythms", "The Energy of Movement", "Vibrant Serenade", "Transcendent Fragments", "Magical Moments", "The Art of Transformation", "Rhythmic Movements", "Vibrant Cityscapes", "Captivating Textures", "Inner reflections", "Journey into Mystery", "Dreamy Watercolors", "Dancing with Time", "Fluid Dynamics", "Whispering Canvases", "Rhythms of the Earth", "Harmony in disarray", "Whispering Waters", "The Language of Color", "Merging Horizons", "The Human Connection", "Uncharted Horizons", "The Human Experience", "The Power of Music", "Wandering Thoughts", "Intertwined Destinies", "Cosmic vibrations", "The Art of Simplicity", "Eternal Serenity", "Textures of Time", "Emerging Identity", "Dreams in Motion", "Fluid Movements", "Ethereal Enigmas", "Dreams of Serenity", "Evolving Textures", "Melodies of the Sea", "The Joy of Simplicity", "Melodies of the Universe", "The Symphony of Life", "Cosmic Kaleidoscope", "Symphony of Solitude", "The art of connection", "The Magic of Texture", "Inner Reflections", "Ethereal Dreams", "Whispers of the Universe", "Infinite Possibilities", "Shifting Perspectives", "Harvesting Memories", "Embracing the Elements", "Surreal Soundscapes", "Evolving Dimensions", "The Language of Dreams", "Soulful Expressions", "Embracing the Unknown", "Breaking Barriers", "Strokes of Brilliance", "Capturing Fragments", "Visions of tomorrow", "Rhythms of the Mind", "Vivid Dreamscape", "Enchanted Forest", "Essence of Silence", "The Magic Within", "Enigmatic Depths", "Urban Poetry", "Unveiled Secrets", "Captivating Curves", "Transcending Dimensions", "Exploring duality", "Translucent Dreams", "Soothing Serenity", "Uncharted Territories Explored", "Timeless elegance", "Eternal Serenade", "Timeless Elegance", "Dancing Brushstrokes", "Curious Connections", "Transcending Dimensions", "Ethereal Beauty", "Mystical Realms", "Emerging from Shadows", "Cosmic Tapestry", "Enigmatic Melodies", "The Dance of Lines", "The Dance of Colors", "Mystical creatures", "Celestial Visions", "The Essence of Life", "Rhythms of the Imagination", "Serenity in Chaos", "Imaginary Horizons", "Cascading Colors", "Mystical Whispers", "Architectural Marvels", "Whispering Whimsy", "Journey of Light", "Melting Colors", "Mystical Enchantments", "The Language of Silence", "Immersive Visions", "Celestial Fragments", "Whirling Motion", "Visions of Tomorrow", "Ethereal beauty", "Layers of Meaning", "Harmony in Form", "Natures Tapestry", "Harvesting Shadows", "Vibrant Contrasts", "Organic Metamorphosis", "The Unseen World", "The Language of Colors", "Unseen Realms", "Reflections of Life", "Timeless Beauty", "Whispers of Time", "Redefining Reality", "Vibrant Surrender", "Harmony in Diversity", "Whispers of Nature", "Silent Echoes", "Visions of Light", "Spectral Visions", "Celestial Beauty", "Transcendent Bliss", "Whimsical Curiosity", "The Fragments of Memory", "Hidden Truths", "Luminous Depths", "Melting Pot", "Surreal Wonderland", "Celestial Harmonies", "Whispered Whimsy", "Melodies of Creation", "Illusions of Reality", "Inner Emotions", "Cityscape Vibes", "Dreamlike Realities", "Urban Jungle", "The Harmony of Opposites", "Journey to Serenity", "Layers of Perception", "Colorful Kaleidoscope", "Evolving identities", "Whispering Secrets", "Whimsical Portraits", "Shadows of the Mind", "Whimsical dreams", "Exploring Identity", "Spectrum of Emotions", "Captivating Curiosity", "Reflections of Identity", "Fragments of Memories", "Cosmic Serenity", "Mystic Mirage", "Whirling Dreams", "Infinite possibilities", "Transcendent Moments", "Enchanted Abstractions", "Blissful Serenity", "Vibrant Echoes", "Exploring the Void", "Sculpting the Soul", "Whispers of the Sea", "Surreal Landscapes", "Vibrant Emotions", "Eternal Euphoria", "The Essence of Silence", "Whispered Secrets Revealed", "Stardust Symphony", "The Dance of Fire", "Flowing Movements", "Stardust Melodies", "Whispered Secrets", "Captivating Fragments", "Mysteries of Time", "The Canvas of Dreams", "Whispers of Infinity", "Abstract impressions", "Cascading Light", "Cosmic Journey", "Celestial Bodies", "Transcending Boundaries", "Shaping the Unknown", "Ripples of Imagination", "Colors of the Soul", "Luminous Transitions", "The Art of Reflection", "Parallel Dimensions", "The Magic of Movement", "The Beauty of Stillness", "Serenade of Light", "Infinite Intricacies", "Illusive Realms", "Enchanted Reverie", "Dancing with Colors", "Whispers of Imagination", "Translucent Transitions", "Ethereal Visions", "Capturing Serendipity", "Rhythm of Creation", "Mosaic of Dreams", "Dreams in Technicolor", "Emotions Unleashed", "The Symphony of Colors", "Beyond the Surface", "Unseen dimensions", "Harvest of Dreams", "The Human Condition", "Melancholic Whimsy", "Surreal Portraits", "Journey to the Soul", "The Energy of Life", "Layers of Existence", "Mystical Enchantment", "Auroras Embrace", "The Mystery of Shadows", "Essence of Serenity", "Emerging Realities", "Fleeting Impressions", "Luminous Enigmas", "Fluid Expressions", "Euphoria in Motion", "Embracing Vulnerability", "Journey into darkness", "The beauty of decay", "The Dance of Time", "Tangled Thoughts", "The beauty of simplicity", "Redefining Perspectives", "Ethereal Whispers", "The Colors of Sound", "Melodies of life", "Emerging Energy", "Symphony of Shadows", "Metamorphic Dreams", "Reverie of Light", "Dreamy Landscapes", "Echoes of the Past", "Shimmering Horizons", "Journey into Light", "Natures Kaleidoscope", "Echoes of the Mind", "The Art of Shadows", "Vibrant Rhythms", "Colorful Fragments", "The Art of Stillness", "Celestial Melodies", "Colors of the Mind", "Magical Realms", "Whispers of Dreams", "Mystical Journeys", "Colorful Whirlwinds", "Transcending Reality", "The Art of Connection", "Symphony of Textures", "Unseen Perspectives", "Whispers of the Soul", "Translucent Veil", "Whispering Dreams", "Waves of Creativity", "Exploring the Unknown", "Ethereal Elegance", "Whimsical Tales", "Metamorphosis of Colors", "Colorful Whispers", "Luminous Reverie", "Ephemeral Fragments", "Mosaic of Memories", "Whirling Fantasies", "The Essence Within", "Vibrant Perspectives", "Eternal Fragility", "Whimsical Wanderlust", "Reimagined Landscapes", "The Fluidity of Nature", "Sculpted Whispers", "Colorful abstractions", "Dreams of Tomorrow", "Unexpected Connections", "Sensory Delights", "Harmony in chaos", "Dynamic Perspectives", "Juxtaposed Elements", "Surreal Dreamscape", "Whimsical Escapes", "Celestial Canvas", "The Poetry of Light", "Ripples of Time", "Whispers of the Sky", "Whispering Echoes", "Merging Perspectives", "Metamorphosis of Life", "Infinite Imagination", "Harmonic Fusion", "The Depths of Emotion", "The Art of Motion", "Untamed Wildness", "Inner Worlds", "The human experience", "Echoes of Stillness", "Rhythms of the Sea", "Rhythm of the Elements", "Metamorphosis of Color", "Temporal Illusions", "The Symphony of Textures", "Sculpting Time", "Mystical Forests", "Whispering Waves", "Celestial Symphony", "Enigmatic Shadows", "Embracing the Unknown", "Whispers of the Mind", "The magic of details", "Embracing Diversity", "The Language of Lines", "Rhythms of nature", "Abstract Color Explosions", "Shadows and light", "Eternal Echoes", "Shades of Serenity", "Fragments of Eternity", "Whirlwind of Emotions", "Symphony of Light", "Enigmatic Horizons", "Unlocking Imagination", "Redefining Boundaries", "Evolving Energies", "Unleashing Creativity", "Chasing Shadows", "Harvest of Memories", "Abstracted Nature", "Abstract Reflections", "Eternal Moments", "Emotional connections", "Unveiled Realities", "Rhythmic Abstractions", "Visions of Tomorrow", "Chromatic Symphony", "Parallel Realities", "Mystic Melodies", "The Symphony of Emotions", "Infinite Horizons", "The Art of Serendipity", "Whispers of the Earth", "The Chaos of Creation", "Echoes of Eternity", "Embracing Imperfection", "Harmony in Chaos", "Celestial Dreams", "Canvas of Dreams", "Urban Exploration", "Embracing the Abstract", "Unfolding Stories", "Interstellar Symphony", "Fluid Abstractions", "The Power of Perspective", "Whispered Memories", "Transcending Boundaries", "Whispers of Creation", "Illusionary Landscapes", "Enchanted Gardens", "The Fragility of Time", "Enigmatic Fragments", "Enchanted Forests", "Sculpted Illusions", "Dreams of Flight", "Unveiled Illusions", "Evolving Perspectives", "Celestial Harmony", "Metamorphosis of life", "Mystical Portals", "Glimpses of Life", "Serenading Raindrops", "Serenading Colors", "Dreamscapes", "Evolving Fragments", "Cosmic Reverie", "The Beauty of Movement", "Captivating Contrasts", "Imaginary landscapes", "Spectrum of Serenity", "Captivating Chaos", "Shaping the Unseen", "Whirling Colors", "Ethereal Enigma", "Whispers of Serenity", "Infinite Perspectives", "Enigmatic Euphoria", "Embracing imperfections", "Essence of Time", "Celestial Awakening", "Rustic Simplicity", "A Glimpse of Eternity", "Infinite Textures", "Translucent Depths", "Vibrant Dreamscape", "Unveiled Connections", "The Serenity of Space", "Abstract Emotions", "Transcendent Whispers", "Serendipitous Encounters", "Soulful Strokes", "Chasing Sunsets", "Timeless Moments", "Cosmic Energy", "Surreal Serenity", "Whispers of the Past", "Whimsical Adventures", "The Power Within", "Celestial Rapture", "The art of solitude", "Illusions of Light", "Harmonious Fusion", "Reflections of Self", "Eternal Enigma", "Inner Landscapes", "Captivating Silence", "Abstract Serenity", "Infinite Curiosity", "Ethereal Essence", "Enigmatic Illusions", "Unveiling Secrets", "Harmonious Contrasts", "Whispers of Light", "The Alchemy of Creation", "Emerging Whispers", "Abstract Color Explosion", "Unveiled Perspectives", "Enchanted Echoes", "Rhythms of the Heart", "The Spirit of Freedom", "Symphony of colors", "Whirling Emotions", "Whimsical Wonder", "Infinite Dimensions", "Eternal Whispers", "Celestial Serenade", "Journey to Infinity", "Uncharted Territories", "Whimsical Wonders", "Whispers of Memories", "Whimsical Wonderland", "Dreamlike Wanderlust", "Colorful Illusions", "Harmony in contrast", "Surreal Symphony", "Beyond the Surface", "Eternal transformations", "Cosmic Wonders", "Ephemeral Beauty", "Whispers of the Sea", "The Souls Journey", "Melancholic Serenity", "Illusive Realities", "Surreal Serenity", "Celestial Fireworks", "Hidden Realities", "Parallel universes", "A World Apart", "Unveiled Emotions", "Dreams of flight", "Capturing Fragility", "Whimsical Wonders", "Rhythms of Nature", "Infinite Connections", "Interstellar Dreams", "Innermost Thoughts", "Emotional Journeys", "Organic Symmetry", "Whispering Colors", "Embracing Vulnerability", "Enigmatic Serenity", "Vibrant Whispers", "Wandering Imagination", "The Magic of Water", "Capturing emotions", "Vibrant Serendipity", "The Essence of Movement", "The Play of Contrasts", "Mystical Creatures", "Soothing Chaos", "Whispers of the soul", "Enchanted Forest Tales", "Melodies of Color", "The Fragility of Life", "The Power of Color", "Whispering Whirlwinds", "The Symphony of Shapes", "Surreal Visions", "The Spirit Within", "Exploring the unknown", "Symmetry in Chaos", "Evolving Dreams", "Cosmic connections", "Translucent Veils", "Dancing Shadows", "Threads of Destiny", "Majestic Whispers", "Suspended Realities", "Dreams and Fantasies", "Surreal Landscapes", "Metamorphosis of Light", "Enchanted Landscapes", "Unveiling Truths", "Emotional Portraits", "Journey of Discovery", "Celestial Explorations", "Shades of Solitude", "Symmetry in Asymmetry", "Uncharted Depths", "Dancing with light", "Wandering Souls", "Surreal Harmonies", "Shadows and Light", "Surreal Serenade", "Surreal Reverie", "Evolving Identities", "Forgotten Memories", "The Power of Silence", "Chaos and Order", "Fragmented Realities", "Evolving Harmonies", "Dreamlike Dalliance", "Rhythms of Life", "Enigmatic Landscapes", "The Spirit of Adventure", "Emotional landscapes", "Magical Realism", "Mystical Serenity", "The Melody of Love", "Whispered Stories", "Sculpting Emotions", "The Fragility of Love", "Whispered Revelations", "The Poetry of Motion", "Rhythm of Life", "Untamed Wilderness", "Cityscapes at Dusk", "Rhythmic Landscapes", "Celestial Fragments", "Symphony of Dreams", "The Dance of Textures", "The Whispers of Wind", "Fleeting Fragments", "Whispering Whirlpools", "Mystical Movements", "The Inner Voice", "The Power of Now", "Whispering winds", "Eternal Inspiration", "Sculpting Shadows", "The Essence of Time", "Hidden Emotions", "The Language of Music", "Merging Realities", "Dreamlike Diversions", "Sculpted Memories", "Ephemeral Essence", "Unveiling Shadows", "Abstract Narratives", "The Magic of Motion", "Ethereal Landscapes", "Whispering Shadows", "The Symphony of Chaos", "Soothing Solitude", "The Intersection of Dreams", "Harmony of Elements", "Merging Horizons", "Dancing with Shadows", "Whispers of the past", "The Poetry of Nature", "Rhythms of Imagination", "Ethereal landscapes", "Whispers of Silence", "Celestial Brushstrokes", "Mystical Rhythms", "The Power of Stillness", "The Dance of Contrast", "Visions of Hope", "Whispers of the Heart", "Transcendent Transitions", "Rhythm of the Sea", "Harmonic Convergence", "The Art of Imperfection", "Unveiling Mystery", "Serenity in Motion", "Harmony Unveiled", "Embracing the Chaos", "Abstract Expressions", "Serenade of Colors", "Surreal Reflections", "Dancing with Color", "Whispering Tides", "Serenity in Chaos", "Symphony of Colors", "Harvesting Dreams", "Imaginary Creatures", "Suspended Animation", "Imagined Landscapes", "Spectral Reflections", "Mystical Reflections", "Melodies in Motion", "Harmony in Nature", "Abstract Whispers", "Urban Jungle Dreams", "Dancing with Light", "Whimsy and Wonder", "Reflections of Light", "Unraveling Mysteries", "Euphoric Elegance", "Shaping Time", "Exploring Contrasts", "Tangled Emotions", "Fleeting Moments Frozen", "The Magic of Details", "Whispered secrets", "Essence of life", "Unveiling the Unknown", "Layers of Identity", "Echoes of silence", "Spectral Whispers", "The Tapestry of Life", "Enchanted Realms", "Celestial Fusion", "Journey Through Time", "Soulful Melodies", "Emerging Dimensions", "The Poetry of Color", "Whimsical Wanderlust", "The Kaleidoscope of Thoughts", "Surreal Realities", "Symphony of Life", "Emotional Landscapes", "Whirling Energies", "Unseen perspectives", "Shades of Wonder", "Journey to the Unknown", "Unveiling Beauty", "The Alchemy of Creation", "Melodies of nature", "Whispers of Memory", "Fragments of Life", "Human Connections", "Echoes of Time", "Melodies of Light", "Surreal visions", "Luminous Shadows", "Shades of Serendipity", "Rhythmic Patterns", "Captured Moments", "Whimsical Creatures", "Embracing Imperfections", "Echoes of the Soul", "Hidden Dimensions", "The rhythm of nature", "Rhythms of the Soul", "Perpetual Motion", "Exploring Inner Landscapes", "Magical realism", "The Essence of Love", "Eternal Flames", "The Power of Emotion", "Cosmic Wonder", "Emerging Patterns", "Lyrical Brushstrokes", "Unveiling the Invisible", "Surreal Symmetry", "Mystical Melodies", "Melodic Vibrations", "Infinite Love", "Vibrant Fusion", "Captured Essence", "Sculpting Dreams", "Cosmic Dreamscape", "Shades of Emotion", "Unseen Dimensions", "Surreal Wonder", "Mystical Mosaics", "The Rhythm of Life", "Invisible Connections", "Cultural Fusion", "Evolving Identity", "Immersed in Texture", "The power of words", "Abstracting Reality", "Reflections of Time", "Liberating Limitations", "Cosmic Rhythms", "Exploring Duality", "Surreal Whispers", "Reimagined Realities", "Euphoric Euphony", "Shattered Illusions", "Unspoken Emotions", "Ethereal Explorations", "Vibrant Reverie", "The essence of time", "The Beauty of Solitude", "Harmony in Motion", "Metamorphosis of Self", "Abstract landscapes", "Mystic Mosaics", "The Harmony of Shapes", "The Fragments of Time", "Eternal Connections", "The Language of Symbols", "The Power of Light", "Journey Within", "Dreamlike Journeys", "Ephemeral Essence", "Unveiling the Unseen", "Vibrant Abstractions", "Hidden Messages", "Enigmatic portraits", "Rhythm of the Universe", "Capturing Timelessness", "Unlocking Creativity", "Eternal Metamorphosis", "The Souls Canvas", "Spectrum of Dreams", "Urban Melodies", "Dancing Fireflies", "Vibrant Energy", "Vibrant Reflections", "Serenade of Silence", "The Beauty of Imperfection", "Serenade of Serenity", "Imaginary Portraits", "Urban reflections", "Dreams and Nightmares", "Melting Pot of Cultures", "Celestial Serenity", "The Complexity of Silence", "Enigmatic Visions", "The Souls Reflection", "Starry Nightscapes", "Whispering Landscapes", "Whirling Energy", "The Magic of Lines", "Fragments of Memory", "Mystical Waters", "The souls journey\"", "Shattered Realities", "Mystic Reverie", "Whimsical Wonderlands", "Spectral Illusions", "Theatrical Illusions", "Celestial wonders", "Emerald Dreamscape", "Into the Abyss", "Surreal Wonderlands", "Whispered Echoes", "Ephemeral Echoes", "Imaginary Worlds", "Cosmic Exploration", "Chasing Rainbows", "Eternal Reflections", "Unveiling Illusions", "The Dance of Elements", "The Fragments of Dreams", "Enchanting Abstractions", "Cosmic Harmony", "The Mystery Within", "Harmonious Fusion", "Enchanted Horizons", "Melting Boundaries", "The power of silence", "Harmony in Disarray", "Dancing with shadows", "Melting Horizons", "Journey into Silence", "Parallel Universes Unveiled", "Rhythm of the Rain", "Whirling Dervishes", "Celestial Whispers", "Vibrant Whirlwind", "Capturing Essence", "Fusion of Elements", "The Power of Imagination", "Surreal Symphony", "Fragments of memories", "Enigmatic Elegance", "Reflections of the Soul", "Journey to the Stars", "Captured Fragments", "Ethereal Euphoria", "Luminous Whispers", "Dancing with Fire", "Exploring Boundaries", "Melodies of the Soul", "Visions of Tranquility", "Uncharted territories", "Unseen Realities", "Embracing Imperfections", "The Whirlwind of Inspiration", "Mystic Visions", "Textures of existence", "Abstract Realities", "Fleeting Eternity", "Sculpted Soundwaves", "Vibrant energy", "Vibrant Serenity", "Evolving Emotions", "Redefining Beauty", "Chromatic Whispers", "Evolving Whispers", "Hidden Beauty", "Transcendent Whispers", "Abstract Alchemy", "The Power of Words", "The Symphony of Senses", "The Essence of Dreams", "Vibrant Reverberations", "Serenading Shadows", "Emotional Resonance", "Transcendent Silence", "Uncharted Realms", "Journey into Abstraction", "Echoes of Nature", "The Unseen Universe", "Sculpted Dreams", "Melodies of the Heart", "Colorful chaos", "Whispering Horizons", "Mosaic of Life", "Melting Time", "Ephemeral Eternity", "Serenade of Textures", "Timeless moments", "Unseen Connections", "Sculpting Memories", "Temporal Fragments", "Harmonious Chaos", "Abstract Euphoria", "Whimsical Abstractions", "Ethereal Watercolors", "Harmony of Colors", "Rhythm of the Soul", "Unspoken Stories", "Curious Contradictions", "Luminous Reflections", "Infinite Echoes", "Exploring Fragility", "The Intersection of Cultures", "Serenading Sunsets", "Ethereal Serenity", "Eternal Fragments", "The Art of Connection", "Embracing Shadows", "Celestial Landscapes", "The Power of Contrast", "Abstract Reverie", "Tales Untold", "Symphony of Shapes", "Chromatic Kaleidoscope", "Ethereal Enchantment", "The Transcendent Journey", "Melancholic Melodies", "Infinite Horizons", "Alchemy of Expression", "Unveiling mysteries", "Organic Abstractions", "Colorful Chaos", "Unraveling Time", "Infinite Depths", "Whirlwind of Thoughts", "Inner Strength", "Vibrant Visions", "Echoes of Emotion", "Rhythms of the city", "Evolving Horizons", "Metamorphosis of nature", "Whimsical Dreams", "Rhythmic Rapture", "Emerging Realities", "Harmony of Contrasts", "Luminous Journeys", "The dance of colors", "Celestial Wonders", "Hidden Worlds Revealed", "Whirlwind of Colors", "Celestial Reflections", "Luminous Illusions", "Temporal Echoes", "Urban Tapestry", "Sensory Explorations", "Harvesting Hope", "Harmony in Contrast", "Eternal Motion", "Whimsical Journey", "Enigmatic Portraits", "Ethereal Reflections", "Urban Illusions", "Abstracted Emotions", "Urban rhythms", "Unspoken narratives", "Journey of Colors", "Spectral Melodies", "Celestial Rhapsody", "Vibrant Brushstrokes", "Journey of the Soul", "Sonic Landscapes", "Celestial Mosaics", "Translucent Dreams", "Textures of Life", "Exploring Dimensions", "Dreamlike Landscapes", "Spiraling Visions", "Ancient Mysteries", "Mysterious Abandon", "Shimmering Dreamscape", "Captivating Illusions", "Transcendent Echoes", "Hidden Meanings", "Metamorphosis of Time", "Reimagining Reality", "The Language of Shapes", "Hidden Beauty Revealed", "Enchanted Visions", "Uncharted Territories", "Journey of self", "The Beauty Within", "Shaping Memories", "Cosmic Whispers", "Embracing Chaos", "Fleeting Moments", "The Ebb and Flow", "Underwater Fantasies", "Parallel Universes", "The Language of Dreams", "The Dance of Light", "The Melody of Light", "The Dance of Nature", "Transcendent Reflections", "Whispers of Inspiration", "Ethereal Landscapes", "Ephemeral Whispers", "Shadows of Tomorrow", "Infinite Horizon", "Dreams Unleashed", "The Dance of Shadows", "Abstracted Realities", "Rhythmic Reverie", "Abstracted Movements", "Spiraling Energy", "Enchanted Whispers", "Abstract Harmony", "Whispering Winds", "Ethereal Dreamscape", "Imaginary Realms", "Uncharted Waters", "Embracing the wild", "Transcendent Beauty", "Curiosity Unleashed", "Synchronized Chaos", "Whispering Whispers", "Serenading Silence", "Captivating Rhythms", "Abstract Illusions", "Shaping Perspectives", "Mystic Reflections", "Surreal fantasies", "Surreal Visions Unveiled", "Abstract Landscapes", "The Essence of Freedom", "Whimsical Whispers", "Colors in Motion", "The language of dreams", "Surreal Symphonies", "Ethereal Echoes", "Infinite Reflections", "The Poetry of Light", "Luminous Landscapes", "Whimsical wonders", "Sculpted Emotions", "Echoes of Silence", "Cosmic Serenade", "Evolving Perspectives", "Unseen Emotions", "Melancholic Whispers", "Urban Melancholy", "Whispered Whispers", "Eternal Transcendence", "Journey to Nowhere", "Infinite Fragments", "Ethereal Essence", "Melodies of Life", "Mystical Mosaic", "Euphorias Embrace", "The Wonder of Discovery", "Vivid Imagination", "Shadows of the Mind", "Unveiling Emotions", "Journey of Shadows", "Journey of Self-Discovery", "Exploring Connections", "Cosmic Vibrations"], "questions": ["An elegant bouquet of red roses and yellow daisies, symbolizing passionate love and innocence respectively, rests on a weathered wooden table in a sunlit room.", "A field of vibrant sunflowers stretches as far as the eye can see, their golden petals turning towards the setting sun, representing adoration and loyalty.", "A solitary white lily, symbolizing purity and rebirth, floats gracefully on the surface of a tranquil pond, its reflection mirroring the surrounding lush greenery.", "A delicate wreath of forget-me-not flowers, representing true love and remembrance, adorns an old gravestone in a forgotten cemetery, as the moon casts an ethereal glow.", "A garden filled with blooming lavender, symbolizing devotion and serenity, where butterflies dance among the fragrant purple flowers in the warm summer breeze.", "A majestic cherry blossom tree stands tall in a park, its delicate pink petals symbolizing beauty and the transient nature of life, as children play beneath its branches.", "A bouquet of blue hydrangeas, representing gratitude and understanding, sits on a rustic wooden bench, awaiting the arrival of a long-lost friend.", "A vine of ivy, symbolizing eternal love and fidelity, gracefully winds its way up the crumbling stone walls of an ancient castle, overlooking a mist-covered valley.", "A vibrant bouquet of orange tulips, symbolizing energy and enthusiasm, adorns a teacher's desk, as curious students eagerly await their next lesson.", "A meadow filled with wildflowers of various colors and shapes, each representing a different emotion, creating a vibrant tapestry of love, joy, and sadness.", "A single red rose, symbolizing passionate love, lies on a weathered love letter, its petals slightly wilted, hinting at a bittersweet ending to a long-distance romance.", "A bouquet of pink carnations, symbolizing a mother's love, sits on a hospital bedside table, bringing comfort and hope to a patient recovering from surgery.", "A trail of delicate daffodils, symbolizing new beginnings and rebirth, winds its way through a dense forest, leading to a hidden clearing bathed in golden sunlight.", "A mystical garden where mystical flowers bloom, each with its own unique power, from a glowing orchid that grants eternal youth to a shimmering poppy that induces vivid dreams.", "A bouquet of white chrysanthemums, symbolizing loyalty and honesty, is presented to a wise elder during a traditional ceremony, honoring their wisdom and guidance.", "A vine of morning glories, symbolizing unrequited love, wraps around an old stone statue in a forgotten garden, as if trying to mend a broken heart.", "A single black rose, symbolizing farewell and death, lies on a weathered gravestone in a desolate cemetery, a symbol of eternal loss and mourning.", "A mystical forest where flowers speak, each with its own distinct voice, creating a symphony of whispered secrets and ancient wisdom.", "A bouquet of rainbow-colored roses, each representing a different emotion, is presented to a performer after an awe-inspiring show, a testament to their ability to evoke various feelings.", "A field of delicate bluebells, symbolizing humility and gratitude, gently sway in the wind, as if whispering their thanks to the world for their existence."], "theme_counter": 0, "question_counter": 0}} \ No newline at end of file +{"text": {"themes": ["Philosopy", "Technology", "Physics", "Ethics", "Academic Writing", "Economy", "History", "Medicine", "Toxicity", "Roleplay", "Entertainment", "Biology", "Counterfactual", "Literature", "Chemistry", "Writing", "Sport", "Law", "Language", "Computer Science", "Multilangual", "Common Sense", "Art", "Complex Format", "Code Generation", "Math", "Code Debug", "Reasoning", "Global Cultures and Societies", "Modern and Ancient Civilizations", "Innovations in Science and Technology", "Environmental Conservation and Biodiversity", "World Religions and Philosophical Thought", "Global Economy and International Trade", "Public Health and Pandemic Response", "Human Rights and Social Justice Issues", "Political Systems and International Relations", "Major Historical Events and their Impact", "Advancements in Medicine and Healthcare", "Fundamentals of Physics and the Cosmos", "Cognitive Development and Learning Theories", "Sustainable Development and Green Technologies", "Media Literacy and News Analysis", "Classical and Modern Literature", "Fundamentals of Mathematics and Logic", "Social Psychology and Group Dynamics", "Emerging Trends in Education", "Civic Engagement and Community Organizing"], "questions": ["Write a program to generate all possible counterfactual scenarios for a given set of conditions.", "Implement a counterfactual analysis algorithm to determine the impact of a specific event on the outcome of a system."], "theme_counter": 0, "question_counter": 0}, "images": {"themes": ["The Inner Journey", "The Dance of Life", "Enigmatic Reflections", "The Poetry of Silence", "Melodies of the Mind", "Whimsical Enigmas", "Whispers of Inspiration", "Colorful Abstractions", "Dancing Colors", "Transcendent moments", "The Essence of Light", "Metamorphosis", "Duality in Nature", "Transcending Time", "Essence of Life", "Ethereal Abstractions", "Hidden Depths", "Urban Rhythms", "Inner emotions", "Whispers of the Night", "Dreams that Soar", "Enchanted Melodies", "Embracing Solitude", "Dreamlike Reflections", "Abstracted Memories", "Melodies of the Mind", "Evolving Realities", "Serenade of Seasons", "Serenity in chaos", "Interwoven Narratives", "Cosmic Connections", "Interplay of elements", "Immersive Portals", "Whispers of the Wind", "Whispered Whimsies", "Painted Passions", "Celestial Strokes", "Imaginary Journeys", "Hidden Treasures", "Shimmering Illusions", "The Strength Within", "Evolving Patterns", "Exploring the Subconscious", "Harmony in Diversity", "Cosmic Dreams", "The Fragile Balance", "Mystical Wanderlust", "Ephemeral Moments", "Whispered Visions", "Metamorphosis of Form", "Capturing Times Essence", "Cascading Emotions", "Whispers of the heart", "Chasing Illusions", "The Fluidity of Form", "Emerging Horizons", "Unveiled Whispers", "Celestial Beings", "... (68 KB left)", "Journey of the Soul", "Transcendent Transparencies", "Tranquil Transcendence", "Luminous Visions", "Sensory Overload", "Exploring identity", "Vibrant Chaos", "The fragility of life", "Eternal Echoes", "Whispers of Wonder", "Whimsical Delights", "Strokes of Serenity", "Rhythm of Colors", "The Art of Silence", "Serenade of Shadows", "Imaginary Landscapes", "Dreams and reality", "Abstract Realities", "Untamed Imagination", "Embracing vulnerability", "Dreamlike Visions", "Melodies of Nature", "Hidden Symmetry", "Mystic Mosaic", "Symphony of Life", "The Art of Transformation", "Reimagining Classics", "Ephemeral beauty", "The Spirit of Movement", "Fragments of Time", "The Beauty of Decay", "The Magic of Childhood", "The Essence of Stillness", "Abstract Energy", "Whirling Vortex", "Parallel Universes Collide", "Whirling Dervish", "Enigmatic Beauty", "The Art of Balance", "Merging Dimensions", "Celestial Rhythms", "The Energy of Movement", "Vibrant Serenade", "Transcendent Fragments", "Magical Moments", "The Art of Transformation", "Rhythmic Movements", "Vibrant Cityscapes", "Captivating Textures", "Inner reflections", "Journey into Mystery", "Dreamy Watercolors", "Dancing with Time", "Fluid Dynamics", "Whispering Canvases", "Rhythms of the Earth", "Harmony in disarray", "Whispering Waters", "The Language of Color", "Merging Horizons", "The Human Connection", "Uncharted Horizons", "The Human Experience", "The Power of Music", "Wandering Thoughts", "Intertwined Destinies", "Cosmic vibrations", "The Art of Simplicity", "Eternal Serenity", "Textures of Time", "Emerging Identity", "Dreams in Motion", "Fluid Movements", "Ethereal Enigmas", "Dreams of Serenity", "Evolving Textures", "Melodies of the Sea", "The Joy of Simplicity", "Melodies of the Universe", "The Symphony of Life", "Cosmic Kaleidoscope", "Symphony of Solitude", "The art of connection", "The Magic of Texture", "Inner Reflections", "Ethereal Dreams", "Whispers of the Universe", "Infinite Possibilities", "Shifting Perspectives", "Harvesting Memories", "Embracing the Elements", "Surreal Soundscapes", "Evolving Dimensions", "The Language of Dreams", "Soulful Expressions", "Embracing the Unknown", "Breaking Barriers", "Strokes of Brilliance", "Capturing Fragments", "Visions of tomorrow", "Rhythms of the Mind", "Vivid Dreamscape", "Enchanted Forest", "Essence of Silence", "The Magic Within", "Enigmatic Depths", "Urban Poetry", "Unveiled Secrets", "Captivating Curves", "Transcending Dimensions", "Exploring duality", "Translucent Dreams", "Soothing Serenity", "Uncharted Territories Explored", "Timeless elegance", "Eternal Serenade", "Timeless Elegance", "Dancing Brushstrokes", "Curious Connections", "Transcending Dimensions", "Ethereal Beauty", "Mystical Realms", "Emerging from Shadows", "Cosmic Tapestry", "Enigmatic Melodies", "The Dance of Lines", "The Dance of Colors", "Mystical creatures", "Celestial Visions", "The Essence of Life", "Rhythms of the Imagination", "Serenity in Chaos", "Imaginary Horizons", "Cascading Colors", "Mystical Whispers", "Architectural Marvels", "Whispering Whimsy", "Journey of Light", "Melting Colors", "Mystical Enchantments", "The Language of Silence", "Immersive Visions", "Celestial Fragments", "Whirling Motion", "Visions of Tomorrow", "Ethereal beauty", "Layers of Meaning", "Harmony in Form", "Natures Tapestry", "Harvesting Shadows", "Vibrant Contrasts", "Organic Metamorphosis", "The Unseen World", "The Language of Colors", "Unseen Realms", "Reflections of Life", "Timeless Beauty", "Whispers of Time", "Redefining Reality", "Vibrant Surrender", "Harmony in Diversity", "Whispers of Nature", "Silent Echoes", "Visions of Light", "Spectral Visions", "Celestial Beauty", "Transcendent Bliss", "Whimsical Curiosity", "The Fragments of Memory", "Hidden Truths", "Luminous Depths", "Melting Pot", "Surreal Wonderland", "Celestial Harmonies", "Whispered Whimsy", "Melodies of Creation", "Illusions of Reality", "Inner Emotions", "Cityscape Vibes", "Dreamlike Realities", "Urban Jungle", "The Harmony of Opposites", "Journey to Serenity", "Layers of Perception", "Colorful Kaleidoscope", "Evolving identities", "Whispering Secrets", "Whimsical Portraits", "Shadows of the Mind", "Whimsical dreams", "Exploring Identity", "Spectrum of Emotions", "Captivating Curiosity", "Reflections of Identity", "Fragments of Memories", "Cosmic Serenity", "Mystic Mirage", "Whirling Dreams", "Infinite possibilities", "Transcendent Moments", "Enchanted Abstractions", "Blissful Serenity", "Vibrant Echoes", "Exploring the Void", "Sculpting the Soul", "Whispers of the Sea", "Surreal Landscapes", "Vibrant Emotions", "Eternal Euphoria", "The Essence of Silence", "Whispered Secrets Revealed", "Stardust Symphony", "The Dance of Fire", "Flowing Movements", "Stardust Melodies", "Whispered Secrets", "Captivating Fragments", "Mysteries of Time", "The Canvas of Dreams", "Whispers of Infinity", "Abstract impressions", "Cascading Light", "Cosmic Journey", "Celestial Bodies", "Transcending Boundaries", "Shaping the Unknown", "Ripples of Imagination", "Colors of the Soul", "Luminous Transitions", "The Art of Reflection", "Parallel Dimensions", "The Magic of Movement", "The Beauty of Stillness", "Serenade of Light", "Infinite Intricacies", "Illusive Realms", "Enchanted Reverie", "Dancing with Colors", "Whispers of Imagination", "Translucent Transitions", "Ethereal Visions", "Capturing Serendipity", "Rhythm of Creation", "Mosaic of Dreams", "Dreams in Technicolor", "Emotions Unleashed", "The Symphony of Colors", "Beyond the Surface", "Unseen dimensions", "Harvest of Dreams", "The Human Condition", "Melancholic Whimsy", "Surreal Portraits", "Journey to the Soul", "The Energy of Life", "Layers of Existence", "Mystical Enchantment", "Auroras Embrace", "The Mystery of Shadows", "Essence of Serenity", "Emerging Realities", "Fleeting Impressions", "Luminous Enigmas", "Fluid Expressions", "Euphoria in Motion", "Embracing Vulnerability", "Journey into darkness", "The beauty of decay", "The Dance of Time", "Tangled Thoughts", "The beauty of simplicity", "Redefining Perspectives", "Ethereal Whispers", "The Colors of Sound", "Melodies of life", "Emerging Energy", "Symphony of Shadows", "Metamorphic Dreams", "Reverie of Light", "Dreamy Landscapes", "Echoes of the Past", "Shimmering Horizons", "Journey into Light", "Natures Kaleidoscope", "Echoes of the Mind", "The Art of Shadows", "Vibrant Rhythms", "Colorful Fragments", "The Art of Stillness", "Celestial Melodies", "Colors of the Mind", "Magical Realms", "Whispers of Dreams", "Mystical Journeys", "Colorful Whirlwinds", "Transcending Reality", "The Art of Connection", "Symphony of Textures", "Unseen Perspectives", "Whispers of the Soul", "Translucent Veil", "Whispering Dreams", "Waves of Creativity", "Exploring the Unknown", "Ethereal Elegance", "Whimsical Tales", "Metamorphosis of Colors", "Colorful Whispers", "Luminous Reverie", "Ephemeral Fragments", "Mosaic of Memories", "Whirling Fantasies", "The Essence Within", "Vibrant Perspectives", "Eternal Fragility", "Whimsical Wanderlust", "Reimagined Landscapes", "The Fluidity of Nature", "Sculpted Whispers", "Colorful abstractions", "Dreams of Tomorrow", "Unexpected Connections", "Sensory Delights", "Harmony in chaos", "Dynamic Perspectives", "Juxtaposed Elements", "Surreal Dreamscape", "Whimsical Escapes", "Celestial Canvas", "The Poetry of Light", "Ripples of Time", "Whispers of the Sky", "Whispering Echoes", "Merging Perspectives", "Metamorphosis of Life", "Infinite Imagination", "Harmonic Fusion", "The Depths of Emotion", "The Art of Motion", "Untamed Wildness", "Inner Worlds", "The human experience", "Echoes of Stillness", "Rhythms of the Sea", "Rhythm of the Elements", "Metamorphosis of Color", "Temporal Illusions", "The Symphony of Textures", "Sculpting Time", "Mystical Forests", "Whispering Waves", "Celestial Symphony", "Enigmatic Shadows", "Embracing the Unknown", "Whispers of the Mind", "The magic of details", "Embracing Diversity", "The Language of Lines", "Rhythms of nature", "Abstract Color Explosions", "Shadows and light", "Eternal Echoes", "Shades of Serenity", "Fragments of Eternity", "Whirlwind of Emotions", "Symphony of Light", "Enigmatic Horizons", "Unlocking Imagination", "Redefining Boundaries", "Evolving Energies", "Unleashing Creativity", "Chasing Shadows", "Harvest of Memories", "Abstracted Nature", "Abstract Reflections", "Eternal Moments", "Emotional connections", "Unveiled Realities", "Rhythmic Abstractions", "Visions of Tomorrow", "Chromatic Symphony", "Parallel Realities", "Mystic Melodies", "The Symphony of Emotions", "Infinite Horizons", "The Art of Serendipity", "Whispers of the Earth", "The Chaos of Creation", "Echoes of Eternity", "Embracing Imperfection", "Harmony in Chaos", "Celestial Dreams", "Canvas of Dreams", "Urban Exploration", "Embracing the Abstract", "Unfolding Stories", "Interstellar Symphony", "Fluid Abstractions", "The Power of Perspective", "Whispered Memories", "Transcending Boundaries", "Whispers of Creation", "Illusionary Landscapes", "Enchanted Gardens", "The Fragility of Time", "Enigmatic Fragments", "Enchanted Forests", "Sculpted Illusions", "Dreams of Flight", "Unveiled Illusions", "Evolving Perspectives", "Celestial Harmony", "Metamorphosis of life", "Mystical Portals", "Glimpses of Life", "Serenading Raindrops", "Serenading Colors", "Dreamscapes", "Evolving Fragments", "Cosmic Reverie", "The Beauty of Movement", "Captivating Contrasts", "Imaginary landscapes", "Spectrum of Serenity", "Captivating Chaos", "Shaping the Unseen", "Whirling Colors", "Ethereal Enigma", "Whispers of Serenity", "Infinite Perspectives", "Enigmatic Euphoria", "Embracing imperfections", "Essence of Time", "Celestial Awakening", "Rustic Simplicity", "A Glimpse of Eternity", "Infinite Textures", "Translucent Depths", "Vibrant Dreamscape", "Unveiled Connections", "The Serenity of Space", "Abstract Emotions", "Transcendent Whispers", "Serendipitous Encounters", "Soulful Strokes", "Chasing Sunsets", "Timeless Moments", "Cosmic Energy", "Surreal Serenity", "Whispers of the Past", "Whimsical Adventures", "The Power Within", "Celestial Rapture", "The art of solitude", "Illusions of Light", "Harmonious Fusion", "Reflections of Self", "Eternal Enigma", "Inner Landscapes", "Captivating Silence", "Abstract Serenity", "Infinite Curiosity", "Ethereal Essence", "Enigmatic Illusions", "Unveiling Secrets", "Harmonious Contrasts", "Whispers of Light", "The Alchemy of Creation", "Emerging Whispers", "Abstract Color Explosion", "Unveiled Perspectives", "Enchanted Echoes", "Rhythms of the Heart", "The Spirit of Freedom", "Symphony of colors", "Whirling Emotions", "Whimsical Wonder", "Infinite Dimensions", "Eternal Whispers", "Celestial Serenade", "Journey to Infinity", "Uncharted Territories", "Whimsical Wonders", "Whispers of Memories", "Whimsical Wonderland", "Dreamlike Wanderlust", "Colorful Illusions", "Harmony in contrast", "Surreal Symphony", "Beyond the Surface", "Eternal transformations", "Cosmic Wonders", "Ephemeral Beauty", "Whispers of the Sea", "The Souls Journey", "Melancholic Serenity", "Illusive Realities", "Surreal Serenity", "Celestial Fireworks", "Hidden Realities", "Parallel universes", "A World Apart", "Unveiled Emotions", "Dreams of flight", "Capturing Fragility", "Whimsical Wonders", "Rhythms of Nature", "Infinite Connections", "Interstellar Dreams", "Innermost Thoughts", "Emotional Journeys", "Organic Symmetry", "Whispering Colors", "Embracing Vulnerability", "Enigmatic Serenity", "Vibrant Whispers", "Wandering Imagination", "The Magic of Water", "Capturing emotions", "Vibrant Serendipity", "The Essence of Movement", "The Play of Contrasts", "Mystical Creatures", "Soothing Chaos", "Whispers of the soul", "Enchanted Forest Tales", "Melodies of Color", "The Fragility of Life", "The Power of Color", "Whispering Whirlwinds", "The Symphony of Shapes", "Surreal Visions", "The Spirit Within", "Exploring the unknown", "Symmetry in Chaos", "Evolving Dreams", "Cosmic connections", "Translucent Veils", "Dancing Shadows", "Threads of Destiny", "Majestic Whispers", "Suspended Realities", "Dreams and Fantasies", "Surreal Landscapes", "Metamorphosis of Light", "Enchanted Landscapes", "Unveiling Truths", "Emotional Portraits", "Journey of Discovery", "Celestial Explorations", "Shades of Solitude", "Symmetry in Asymmetry", "Uncharted Depths", "Dancing with light", "Wandering Souls", "Surreal Harmonies", "Shadows and Light", "Surreal Serenade", "Surreal Reverie", "Evolving Identities", "Forgotten Memories", "The Power of Silence", "Chaos and Order", "Fragmented Realities", "Evolving Harmonies", "Dreamlike Dalliance", "Rhythms of Life", "Enigmatic Landscapes", "The Spirit of Adventure", "Emotional landscapes", "Magical Realism", "Mystical Serenity", "The Melody of Love", "Whispered Stories", "Sculpting Emotions", "The Fragility of Love", "Whispered Revelations", "The Poetry of Motion", "Rhythm of Life", "Untamed Wilderness", "Cityscapes at Dusk", "Rhythmic Landscapes", "Celestial Fragments", "Symphony of Dreams", "The Dance of Textures", "The Whispers of Wind", "Fleeting Fragments", "Whispering Whirlpools", "Mystical Movements", "The Inner Voice", "The Power of Now", "Whispering winds", "Eternal Inspiration", "Sculpting Shadows", "The Essence of Time", "Hidden Emotions", "The Language of Music", "Merging Realities", "Dreamlike Diversions", "Sculpted Memories", "Ephemeral Essence", "Unveiling Shadows", "Abstract Narratives", "The Magic of Motion", "Ethereal Landscapes", "Whispering Shadows", "The Symphony of Chaos", "Soothing Solitude", "The Intersection of Dreams", "Harmony of Elements", "Merging Horizons", "Dancing with Shadows", "Whispers of the past", "The Poetry of Nature", "Rhythms of Imagination", "Ethereal landscapes", "Whispers of Silence", "Celestial Brushstrokes", "Mystical Rhythms", "The Power of Stillness", "The Dance of Contrast", "Visions of Hope", "Whispers of the Heart", "Transcendent Transitions", "Rhythm of the Sea", "Harmonic Convergence", "The Art of Imperfection", "Unveiling Mystery", "Serenity in Motion", "Harmony Unveiled", "Embracing the Chaos", "Abstract Expressions", "Serenade of Colors", "Surreal Reflections", "Dancing with Color", "Whispering Tides", "Serenity in Chaos", "Symphony of Colors", "Harvesting Dreams", "Imaginary Creatures", "Suspended Animation", "Imagined Landscapes", "Spectral Reflections", "Mystical Reflections", "Melodies in Motion", "Harmony in Nature", "Abstract Whispers", "Urban Jungle Dreams", "Dancing with Light", "Whimsy and Wonder", "Reflections of Light", "Unraveling Mysteries", "Euphoric Elegance", "Shaping Time", "Exploring Contrasts", "Tangled Emotions", "Fleeting Moments Frozen", "The Magic of Details", "Whispered secrets", "Essence of life", "Unveiling the Unknown", "Layers of Identity", "Echoes of silence", "Spectral Whispers", "The Tapestry of Life", "Enchanted Realms", "Celestial Fusion", "Journey Through Time", "Soulful Melodies", "Emerging Dimensions", "The Poetry of Color", "Whimsical Wanderlust", "The Kaleidoscope of Thoughts", "Surreal Realities", "Symphony of Life", "Emotional Landscapes", "Whirling Energies", "Unseen perspectives", "Shades of Wonder", "Journey to the Unknown", "Unveiling Beauty", "The Alchemy of Creation", "Melodies of nature", "Whispers of Memory", "Fragments of Life", "Human Connections", "Echoes of Time", "Melodies of Light", "Surreal visions", "Luminous Shadows", "Shades of Serendipity", "Rhythmic Patterns", "Captured Moments", "Whimsical Creatures", "Embracing Imperfections", "Echoes of the Soul", "Hidden Dimensions", "The rhythm of nature", "Rhythms of the Soul", "Perpetual Motion", "Exploring Inner Landscapes", "Magical realism", "The Essence of Love", "Eternal Flames", "The Power of Emotion", "Cosmic Wonder", "Emerging Patterns", "Lyrical Brushstrokes", "Unveiling the Invisible", "Surreal Symmetry", "Mystical Melodies", "Melodic Vibrations", "Infinite Love", "Vibrant Fusion", "Captured Essence", "Sculpting Dreams", "Cosmic Dreamscape", "Shades of Emotion", "Unseen Dimensions", "Surreal Wonder", "Mystical Mosaics", "The Rhythm of Life", "Invisible Connections", "Cultural Fusion", "Evolving Identity", "Immersed in Texture", "The power of words", "Abstracting Reality", "Reflections of Time", "Liberating Limitations", "Cosmic Rhythms", "Exploring Duality", "Surreal Whispers", "Reimagined Realities", "Euphoric Euphony", "Shattered Illusions", "Unspoken Emotions", "Ethereal Explorations", "Vibrant Reverie", "The essence of time", "The Beauty of Solitude", "Harmony in Motion", "Metamorphosis of Self", "Abstract landscapes", "Mystic Mosaics", "The Harmony of Shapes", "The Fragments of Time", "Eternal Connections", "The Language of Symbols", "The Power of Light", "Journey Within", "Dreamlike Journeys", "Ephemeral Essence", "Unveiling the Unseen", "Vibrant Abstractions", "Hidden Messages", "Enigmatic portraits", "Rhythm of the Universe", "Capturing Timelessness", "Unlocking Creativity", "Eternal Metamorphosis", "The Souls Canvas", "Spectrum of Dreams", "Urban Melodies", "Dancing Fireflies", "Vibrant Energy", "Vibrant Reflections", "Serenade of Silence", "The Beauty of Imperfection", "Serenade of Serenity", "Imaginary Portraits", "Urban reflections", "Dreams and Nightmares", "Melting Pot of Cultures", "Celestial Serenity", "The Complexity of Silence", "Enigmatic Visions", "The Souls Reflection", "Starry Nightscapes", "Whispering Landscapes", "Whirling Energy", "The Magic of Lines", "Fragments of Memory", "Mystical Waters", "The souls journey\"", "Shattered Realities", "Mystic Reverie", "Whimsical Wonderlands", "Spectral Illusions", "Theatrical Illusions", "Celestial wonders", "Emerald Dreamscape", "Into the Abyss", "Surreal Wonderlands", "Whispered Echoes", "Ephemeral Echoes", "Imaginary Worlds", "Cosmic Exploration", "Chasing Rainbows", "Eternal Reflections", "Unveiling Illusions", "The Dance of Elements", "The Fragments of Dreams", "Enchanting Abstractions", "Cosmic Harmony", "The Mystery Within", "Harmonious Fusion", "Enchanted Horizons", "Melting Boundaries", "The power of silence", "Harmony in Disarray", "Dancing with shadows", "Melting Horizons", "Journey into Silence", "Parallel Universes Unveiled", "Rhythm of the Rain", "Whirling Dervishes", "Celestial Whispers", "Vibrant Whirlwind", "Capturing Essence", "Fusion of Elements", "The Power of Imagination", "Surreal Symphony", "Fragments of memories", "Enigmatic Elegance", "Reflections of the Soul", "Journey to the Stars", "Captured Fragments", "Ethereal Euphoria", "Luminous Whispers", "Dancing with Fire", "Exploring Boundaries", "Melodies of the Soul", "Visions of Tranquility", "Uncharted territories", "Unseen Realities", "Embracing Imperfections", "The Whirlwind of Inspiration", "Mystic Visions", "Textures of existence", "Abstract Realities", "Fleeting Eternity", "Sculpted Soundwaves", "Vibrant energy", "Vibrant Serenity", "Evolving Emotions", "Redefining Beauty", "Chromatic Whispers", "Evolving Whispers", "Hidden Beauty", "Transcendent Whispers", "Abstract Alchemy", "The Power of Words", "The Symphony of Senses", "The Essence of Dreams", "Vibrant Reverberations", "Serenading Shadows", "Emotional Resonance", "Transcendent Silence", "Uncharted Realms", "Journey into Abstraction", "Echoes of Nature", "The Unseen Universe", "Sculpted Dreams", "Melodies of the Heart", "Colorful chaos", "Whispering Horizons", "Mosaic of Life", "Melting Time", "Ephemeral Eternity", "Serenade of Textures", "Timeless moments", "Unseen Connections", "Sculpting Memories", "Temporal Fragments", "Harmonious Chaos", "Abstract Euphoria", "Whimsical Abstractions", "Ethereal Watercolors", "Harmony of Colors", "Rhythm of the Soul", "Unspoken Stories", "Curious Contradictions", "Luminous Reflections", "Infinite Echoes", "Exploring Fragility", "The Intersection of Cultures", "Serenading Sunsets", "Ethereal Serenity", "Eternal Fragments", "The Art of Connection", "Embracing Shadows", "Celestial Landscapes", "The Power of Contrast", "Abstract Reverie", "Tales Untold", "Symphony of Shapes", "Chromatic Kaleidoscope", "Ethereal Enchantment", "The Transcendent Journey", "Melancholic Melodies", "Infinite Horizons", "Alchemy of Expression", "Unveiling mysteries", "Organic Abstractions", "Colorful Chaos", "Unraveling Time", "Infinite Depths", "Whirlwind of Thoughts", "Inner Strength", "Vibrant Visions", "Echoes of Emotion", "Rhythms of the city", "Evolving Horizons", "Metamorphosis of nature", "Whimsical Dreams", "Rhythmic Rapture", "Emerging Realities", "Harmony of Contrasts", "Luminous Journeys", "The dance of colors", "Celestial Wonders", "Hidden Worlds Revealed", "Whirlwind of Colors", "Celestial Reflections", "Luminous Illusions", "Temporal Echoes", "Urban Tapestry", "Sensory Explorations", "Harvesting Hope", "Harmony in Contrast", "Eternal Motion", "Whimsical Journey", "Enigmatic Portraits", "Ethereal Reflections", "Urban Illusions", "Abstracted Emotions", "Urban rhythms", "Unspoken narratives", "Journey of Colors", "Spectral Melodies", "Celestial Rhapsody", "Vibrant Brushstrokes", "Journey of the Soul", "Sonic Landscapes", "Celestial Mosaics", "Translucent Dreams", "Textures of Life", "Exploring Dimensions", "Dreamlike Landscapes", "Spiraling Visions", "Ancient Mysteries", "Mysterious Abandon", "Shimmering Dreamscape", "Captivating Illusions", "Transcendent Echoes", "Hidden Meanings", "Metamorphosis of Time", "Reimagining Reality", "The Language of Shapes", "Hidden Beauty Revealed", "Enchanted Visions", "Uncharted Territories", "Journey of self", "The Beauty Within", "Shaping Memories", "Cosmic Whispers", "Embracing Chaos", "Fleeting Moments", "The Ebb and Flow", "Underwater Fantasies", "Parallel Universes", "The Language of Dreams", "The Dance of Light", "The Melody of Light", "The Dance of Nature", "Transcendent Reflections", "Whispers of Inspiration", "Ethereal Landscapes", "Ephemeral Whispers", "Shadows of Tomorrow", "Infinite Horizon", "Dreams Unleashed", "The Dance of Shadows", "Abstracted Realities", "Rhythmic Reverie", "Abstracted Movements", "Spiraling Energy", "Enchanted Whispers", "Abstract Harmony", "Whispering Winds", "Ethereal Dreamscape", "Imaginary Realms", "Uncharted Waters", "Embracing the wild", "Transcendent Beauty", "Curiosity Unleashed", "Synchronized Chaos", "Whispering Whispers", "Serenading Silence", "Captivating Rhythms", "Abstract Illusions", "Shaping Perspectives", "Mystic Reflections", "Surreal fantasies", "Surreal Visions Unveiled", "Abstract Landscapes", "The Essence of Freedom", "Whimsical Whispers", "Colors in Motion", "The language of dreams", "Surreal Symphonies", "Ethereal Echoes", "Infinite Reflections", "The Poetry of Light", "Luminous Landscapes", "Whimsical wonders", "Sculpted Emotions", "Echoes of Silence", "Cosmic Serenade", "Evolving Perspectives", "Unseen Emotions", "Melancholic Whispers", "Urban Melancholy", "Whispered Whispers", "Eternal Transcendence", "Journey to Nowhere", "Infinite Fragments", "Ethereal Essence", "Melodies of Life", "Mystical Mosaic", "Euphorias Embrace", "The Wonder of Discovery", "Vivid Imagination", "Shadows of the Mind", "Unveiling Emotions", "Journey of Shadows", "Journey of Self-Discovery", "Exploring Connections", "Cosmic Vibrations", "The Language of Flowers", "Mystical Landscapes"], "questions": ["1. A vibrant rainbow serpent slithers through a dense forest, leaving a trail of multi-colored leaves in its wake.", "2. In a bustling city, a street artist transforms a dull gray wall into a breathtaking mural bursting with vivid hues and intricate patterns.", "3. A hot air balloon floats gracefully over a vast field of blooming wildflowers, each petal displaying a different shade of the rainbow.", "4. Deep in an underwater cave, bioluminescent creatures illuminate the darkness, creating a mesmerizing display of neon colors.", "5. On a snowy mountaintop, a group of skiers carve colorful trails in the snow, leaving behind a kaleidoscope of vibrant lines.", "6. In a desert oasis, a flock of brilliantly plumaged birds take flight, their feathers shimmering in the sunlight like a rainbow.", "7. At a bustling market, vendors sell spices from all corners of the world, their vibrant colors creating a sensory feast for the eyes.", "8. In a futuristic cityscape, holographic billboards project vivid images that dance with a myriad of colors, captivating passersby.", "9. A field of sunflowers stretches as far as the eye can see, their bright yellow petals contrasting against a clear blue sky.", "10. In a mystical forest, fireflies create a breathtaking light show, their bioluminescent glow casting an ethereal rainbow across the trees."], "theme_counter": 0, "question_counter": 0}} \ No newline at end of file diff --git a/template/protocol.py b/template/protocol.py index fb32ef5c..8f790042 100644 --- a/template/protocol.py +++ b/template/protocol.py @@ -21,6 +21,7 @@ class IsAlive( bt.Synapse ): class ImageResponse(bt.Synapse): """ A class to represent the response for an image-related request. """ + # https://platform.stability.ai/docs/api-reference#tag/v1generation/operation/textToImage completion: Optional[Dict] = pydantic.Field( None, @@ -41,37 +42,68 @@ class ImageResponse(bt.Synapse): ) seed: int = pydantic.Field( - ..., + default=1234, title="Seed", description="The seed that which to generate the image with" ) + samples: int = pydantic.Field( + default=1, + title="Samples", + description="The number of samples to generate" + ) + + cfg_scale: float = pydantic.Field( + default=8.0, + title="cfg_scale", + description="The cfg_scale to use for image generation" + ) + + # (Available Samplers: ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_dpmpp_2s_ancestral, k_lms, k_dpmpp_2m, k_dpmpp_sde) + sampler: str = pydantic.Field( + default="", + title="Sampler", + description="The sampler to use for image generation" + ) + steps: int = pydantic.Field( - ..., + default=30, title="Seed", description="The steps to take in generating the image" ) model: str = pydantic.Field( - ..., + default="dall-e-2", title="Model", description="The model used for generating the image." ) style: str = pydantic.Field( - ..., + default="vivid", title="Style", description="The style of the image." ) size: str = pydantic.Field( - ..., - title="Size", + default="1024x1024", + title="The size of the image, used for Openai generation. Options are 1024x1024, 1792x1024, 1024x1792 for dalle3", description="The size of the image." ) + height: int = pydantic.Field( + default=1024, + title="Height used for non Openai images", + description="height" + ) + + width: int = pydantic.Field( + default=1024, + title="Width used for non Openai images", + description="width" + ) + quality: str = pydantic.Field( - ..., + default="standard", title="Quality", description="The quality of the image." ) @@ -96,7 +128,7 @@ class Embeddings( bt.Synapse): ) model: str = pydantic.Field( - "text-embedding-ada-002", + default="text-embedding-ada-002", title="Model", description="The model used for generating embeddings." ) @@ -127,7 +159,7 @@ class StreamPrompting(bt.StreamingSynapse): ) seed: int = pydantic.Field( - "", + default="1234", title="Seed", description="Seed for text generation. This attribute is immutable and cannot be updated.", ) @@ -140,28 +172,28 @@ class StreamPrompting(bt.StreamingSynapse): ) max_tokens: int = pydantic.Field( - 2048, + default=2048, title="Max Tokens", description="Max tokens for text generation. " "This attribute is immutable and cannot be updated.", ) top_p: float = pydantic.Field( - 0.001, + defalt=0.001, title="Max Tokens", description="Max tokens for text generation. " "This attribute is immutable and cannot be updated.", ) top_k: int = pydantic.Field( - 1, + default=1, title="Max Tokens", description="Max tokens for text generation. " "This attribute is immutable and cannot be updated.", ) completion: str = pydantic.Field( - "", + None, title="Completion", description="Completion status of the current StreamPrompting object. " "This attribute is mutable and can be updated.", @@ -174,7 +206,7 @@ class StreamPrompting(bt.StreamingSynapse): ) model: str = pydantic.Field( - "", + default="gpt-3.5-turbo", title="model", description="The model to use when calling provider for your response.", ) diff --git a/template/reward.py b/template/reward.py index 34b236fe..d55cb10d 100644 --- a/template/reward.py +++ b/template/reward.py @@ -34,13 +34,13 @@ import numpy as np from numpy.linalg import norm import bittensor as bt +from template import utils from PIL import Image from scipy.spatial.distance import cosine from sklearn.metrics.pairwise import cosine_similarity from sklearn.feature_extraction.text import TfidfVectorizer from transformers import CLIPProcessor, CLIPModel - # ==== TEXT ==== def calculate_text_similarity(text1: str, text2: str): @@ -151,7 +151,7 @@ def calculate_image_similarity(image, description, max_length: int = 77): # Calculate cosine similarity return torch.cosine_similarity(image_embedding, text_embedding, dim=1).item() -async def image_score(uid, url, desired_size, description, weight, similarity_threshold=0.23) -> float: +async def dalle_score(uid, url, desired_size, description, weight, similarity_threshold=0.23) -> float: """Calculate the image score based on similarity and size asynchronously.""" if not re.match(url_regex, url): @@ -188,6 +188,20 @@ async def image_score(uid, url, desired_size, description, weight, similarity_th return 0 + +# IMAGES ---- DETERMINISTIC + +async def deterministic_score(uid: int, syn, weight: float): + vali_b64s = await utils.call_stability(syn.messages, syn.seed, syn.steps, syn.cfg_scale, syn.width, syn.height, syn.samples, syn.sampler) + + for miner_b64, vali_b64 in zip(syn.completion["b64s"], vali_b64s): + if miner_b64[:50] != vali_b64[:50]: + return 0 + + return weight + + + # ==== Embeddings ===== async def embeddings_score(openai_answer: list, response: list, weight: float, threshold: float = .95) -> float: diff --git a/template/utils.py b/template/utils.py index 14762b4d..71a83e09 100644 --- a/template/utils.py +++ b/template/utils.py @@ -1,18 +1,24 @@ from __future__ import annotations +import io import ast import asyncio import base64 import json import boto3 +import base64 import math import os import random import re +import requests +from PIL import Image import traceback import anthropic from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT from typing import Optional +from stability_sdk import client as stability_client +import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation import bittensor as bt import requests @@ -26,14 +32,21 @@ import anthropic_bedrock from anthropic_bedrock import AsyncAnthropicBedrock +# Set up the API connection +stability_api = stability_client.StabilityInference( + key=os.environ['STABILITY_KEY'], + verbose=True, + engine="stable-diffusion-xl-1024-v1-0" +) -def load_state_from_file(filename: str = "validators/state.json"): + +def load_state_from_file(filename: str = "state.json"): if os.path.exists(filename): with open(filename, "r") as file: - bt.logging.info("loaded previous state") + bt.logging.debug("loaded previous state") return json.load(file) else: - bt.logging.info("initialized new global state") + bt.logging.debug("initialized new global state") return { "text": {"themes": None, "questions": None, "theme_counter": 0, "question_counter": 0}, "images": {"themes": None, "questions": None, "theme_counter": 0, "question_counter": 0} @@ -302,7 +315,7 @@ def extract_python_list(text: str): return convert_to_list(text) text = preprocess_string(text) - bt.logging.debug(f"Postprocessed text = {text}") + bt.logging.trace(f"Postprocessed text = {text}") # Extracting list enclosed in square brackets match = re.search(r'\[((?:[^][]|"(?:\\.|[^"\\])*")*)\]', text, re.DOTALL) @@ -333,7 +346,7 @@ async def call_openai(messages, temperature, model, seed=1234, max_tokens=2048, top_p=top_p, ) response = response.choices[0].message.content - bt.logging.debug(f"validator response is {response}") + bt.logging.trace(f"validator response is {response}") return response except Exception as e: @@ -381,13 +394,34 @@ async def call_anthropic(prompt, temperature, model, max_tokens=2048, top_p=1, t top_p=top_p, top_k=top_k, ) - bt.logging.debug(f"Validator response is {completion.completion}") + bt.logging.trace(f"Validator response is {completion.completion}") return completion.completion except Exception as e: bt.logging.error(f"Error when calling Anthropic: {traceback.format_exc()}") await asyncio.sleep(0.5) +async def call_stability(prompt, seed, steps, cfg_scale, width, height, samples, sampler): + bt.logging.debug(f"calling stability for {prompt, seed, steps, cfg_scale, width, height, samples, sampler}") + + # Run the synchronous stability_api.generate function in a separate thread + meta = await asyncio.to_thread( + stability_api.generate, + prompt=prompt, + seed=seed, + steps=steps, + cfg_scale=cfg_scale, + width=width, + height=height, + samples=samples, + # sampler=sampler, + ) + + # Convert image binary data to base64 + b64s = [base64.b64encode(artifact.binary).decode() for image in meta for artifact in image.artifacts] + + return b64s + # Github unauthorized rate limit of requests per hour is 60. Authorized is 5000. diff --git a/test_scripts/compare_stability.py b/test_scripts/compare_stability.py new file mode 100644 index 00000000..3b30e731 --- /dev/null +++ b/test_scripts/compare_stability.py @@ -0,0 +1,45 @@ +import base64 +import time +import os +from stability_sdk import client +import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation + +start_time = time.time() + +# Set up the API connection +stability_api = client.StabilityInference( + key=os.environ['STABILITY_KEY'], + verbose=True, + engine="stable-diffusion-xl-1024-v1-0" +) + +# Base64 Comparison +def base64_comparison(data1, data2): + return data1 == data2 + +# Generate images and get their base64 representations +data = ('Stability', 'stable-diffusion-xl-1024-v1-0', 'halla halla, we dem boys', '1024x1024', 1024, 1024, 'standard', 'vivid', 656827, 30, None, 8.0, 'SAMPLER_K_DPMPP_2M', 9, 1) + +meta = stability_api.generate( + prompt=data[2], + seed=data[8], + steps=data[-6], + cfg_scale=data[-4], + width=data[-11], + height=data[-10], + samples=data[-1], + sampler=data[-3], +) + +# Convert image binary data to base64 +base64_images = [] +for image in meta: + for artifact in image.artifacts: + base64_images.append(base64.b64encode(artifact.binary).decode()) + base64_images.append(base64.b64encode(artifact.binary).decode()) + +# Time and compare using Base64 Comparison +base64_result = base64_comparison(base64_images[0], base64_images[1]) +base64_duration = time.time() - start_time +print(f"Base64 Comparison: {base64_result}, Time taken: {base64_duration} seconds") + diff --git a/test_scripts/test_stability.py b/test_scripts/test_stability.py index ee2d8529..b938205e 100644 --- a/test_scripts/test_stability.py +++ b/test_scripts/test_stability.py @@ -12,32 +12,62 @@ engine="stable-diffusion-xl-1024-v1-0" ) -# Generate the image -answers = stability_api.generate( - prompt="expansive landscape rolling greens with gargantuan yggdrasil, intricate world-spanning roots towering under a blue alien sky, masterful, ghibli", - seed=4253978046, - steps=30, - cfg_scale=8.0, - width=1024, - height=1024, - samples=1, - sampler=generation.SAMPLER_K_DPMPP_2M +# # Generate the image +# answers = stability_api.generate( +# prompt="expansive landscape rolling greens with gargantuan yggdrasil, intricate world-spanning roots towering under a blue alien sky, masterful, ghibli", +# seed=9283409, +# steps=30, +# cfg_scale=8.0, +# width=1024, +# height=1024, +# samples=1, +# sampler=generation.SAMPLER_K_DPMPP_2M +# ) + +# # Process and upload the image +# for resp in answers: +# for artifact in resp.artifacts: +# if artifact.finish_reason == generation.FILTER: +# print("Safety filters activated, prompt could not be processed.") +# elif artifact.type == generation.ARTIFACT_IMAGE: +# img = Image.open(io.BytesIO(artifact.binary)) +# img_buffer = io.BytesIO() +# img.save(img_buffer, format="PNG") +# img_buffer.seek(0) + +# # Upload to file.io +# response = requests.post('https://file.io', files={'file': img_buffer}) +# if response.status_code == 200: +# print(f"Image uploaded successfully. URL: {response.json()['link']}") +# else: +# print("Failed to upload the image.") + +prompt = 'halla halla, we dem boys' + +data = ('Stability', 'stable-diffusion-xl-1024-v1-0', prompt, '1024x1024', 1024, 1024, 'standard', 'vivid', 656827, 30, None, 8.0, 'SAMPLER_K_DPMPP_2M', 9, 1) + +meta = stability_api.generate( + prompt=data[2], + seed=data[8], + steps=data[-6], + cfg_scale=data[-4], + width=data[-11], + height=data[-10], + samples=data[-1], + sampler=data[-3], ) # Process and upload the image -for resp in answers: - for artifact in resp.artifacts: - if artifact.finish_reason == generation.FILTER: - print("Safety filters activated, prompt could not be processed.") - elif artifact.type == generation.ARTIFACT_IMAGE: - img = Image.open(io.BytesIO(artifact.binary)) - img_buffer = io.BytesIO() - img.save(img_buffer, format="PNG") - img_buffer.seek(0) - - # Upload to file.io - response = requests.post('https://file.io', files={'file': img_buffer}) - if response.status_code == 200: - print(f"Image uploaded successfully. URL: {response.json()['link']}") - else: - print("Failed to upload the image.") +for image in meta: + for artifact in image.artifacts: + img = Image.open(io.BytesIO(artifact.binary)) + img_buffer = io.BytesIO() + img.save(img_buffer, format="PNG") + img_buffer.seek(0) + # Upload to file.io + response = requests.post('https://file.io', files={'file': img_buffer}) + if response.status_code == 200: + image_url = response.json()['link'] + print(image_url) + else: + bt.logging.error("Failed to upload the image.") \ No newline at end of file diff --git a/validators/base_validator.py b/validators/base_validator.py index 7abae535..0ff2254c 100644 --- a/validators/base_validator.py +++ b/validators/base_validator.py @@ -34,5 +34,7 @@ async def score_responses(self, responses): ... async def get_and_score(self, available_uids, metagraph): + bt.logging.info("starting query") query_responses, uid_to_question = await self.start_query(available_uids, metagraph) + bt.logging.info("scoring query") return await self.score_responses(query_responses, uid_to_question, metagraph) diff --git a/validators/image_validator.py b/validators/image_validator.py index 49e3003a..3fa3573b 100644 --- a/validators/image_validator.py +++ b/validators/image_validator.py @@ -1,8 +1,11 @@ +import io import torch import wandb import random import asyncio import aiohttp +import base64 +import traceback import template.reward import bittensor as bt @@ -18,16 +21,16 @@ def __init__(self, dendrite, config, subtensor, wallet): super().__init__(dendrite, config, subtensor, wallet, timeout=60) self.streaming = False self.query_type = "images" - self.model = "dall-e-3" - self.weight = .35 - self.provider = "DallE" - self.size = "1792x1024" + self.model = "dall-e-2" + self.weight = .5 + self.provider = "OpenAI" + self.size = "1024x1024" + self.width = 1024 + self.height = 1024 self.quality = "standard" self.style = "vivid" self.steps = 30 - - self.provider = None - + self.seed = 12345 self.wandb_data = { "modality": "images", "prompts": {}, @@ -38,91 +41,113 @@ def __init__(self, dendrite, config, subtensor, wallet): } async def start_query(self, available_uids, metagraph): - # Randomly choose the provider based on specified probabilities - providers = ["DallE"] * 2 + ["Stability"] * 8 - self.provider = random.choice(providers) - - if self.provider == "Stability": - seed = random.randint(1000, 1000000) - self.model = "stable-diffusion-xl-1024-v1-0" - - # Query all images concurrently - query_tasks = [] - uid_to_messages = {} - for uid in available_uids: - bt.logging.debug(f"sending question to {uid}") - messages = await get_question("images", len(available_uids)) - uid_to_messages[uid] = messages # Store messages for each UID - - syn = ImageResponse(messages=messages, model=self.model, size=self.size, quality=self.quality, style=self.style, provider=self.provider, seed=None) - bt.logging.info( - f"Sending a {self.size} {self.quality} {self.style} {self.query_type} request " - f"to uid: {uid} using {syn.model} with timeout {self.timeout}: {syn.messages}" - ) - task = self.query_miner(metagraph, uid, syn) - query_tasks.append(task) - self.wandb_data["prompts"][uid] = messages - - query_responses = await asyncio.gather(*query_tasks) - return query_responses, uid_to_messages - - async def download_image(self, url): - async with aiohttp.ClientSession() as session: - async with session.get(url) as response: - content = await response.read() - return Image.open(BytesIO(content)) - - async def score_responses(self, query_responses, uid_to_messages, metagraph): + try: + query_tasks = [] + uid_to_question = {} + + # Randomly choose the provider based on specified probabilities + providers = ["OpenAI"] * 5 + ["Stability"] * 5 + self.provider = random.choice(providers) + + if self.provider == "Stability": + self.seed = random.randint(1000, 1000000) + self.model = "stable-diffusion-xl-1024-v1-0" + + elif self.provider == "OpenAI": + self.model = "dall-e-2" + + # Query all images concurrently + for uid in available_uids: + messages = await get_question("images", len(available_uids)) + uid_to_question[uid] = messages # Store messages for each UID + + syn = ImageResponse(messages=messages, model=self.model, size=self.size, quality=self.quality, style=self.style, provider=self.provider, seed=self.seed, steps=self.steps) + bt.logging.info(f"uid = {uid}, syn = {syn}") + + # bt.logging.info( + # f"Sending a {self.size} {self.quality} {self.style} {self.query_type} request " + # f"to uid: {uid} using {syn.model} with timeout {self.timeout}: {syn.messages}" + # ) + task = self.query_miner(metagraph, uid, syn) + query_tasks.append(task) + self.wandb_data["prompts"][uid] = messages + + # Query responses is (uid. syn) + query_responses = await asyncio.gather(*query_tasks) + return query_responses, uid_to_question + except: + bt.logging.error(f"error in start_query {traceback.format_exc()}") + + + async def b64_to_image(self, b64): + image_data = base64.b64decode(b64) + return await asyncio.to_thread(Image.open, BytesIO(image_data)) + + async def download_image(self, url, session): + async with session.get(url) as response: + content = await response.read() + return await asyncio.to_thread(Image.open, BytesIO(content)) + + async def process_download_result(self, uid, download_task): + try: + image = await download_task + self.wandb_data["images"][uid] = wandb.Image(image) + except Exception as e: + bt.logging.error(f"Error downloading image for UID {uid}: {e}") + + async def process_score_result(self, uid, score_task, scores, uid_scores_dict): + try: + scored_response = await score_task + score = scored_response if scored_response is not None else 0 + scores[uid] = uid_scores_dict[uid] = score + except Exception as e: + bt.logging.error(f"Error scoring image for UID {uid}: {e}") + + async def score_responses(self, query_responses, uid_to_question, metagraph): scores = torch.zeros(len(metagraph.hotkeys)) uid_scores_dict = {} download_tasks = [] score_tasks = [] - - # Decide to score all UIDs this round based on a chance - random_number = random.random() - will_score_all = random_number < 1/5 - bt.logging.info(f"Random Number: {random_number}, Will score image responses: {will_score_all}") - - for uid, response in query_responses: - if not response: - bt.logging.debug(f"No response for UID {uid}") - scores[uid] = 0 - uid_scores_dict[uid] = 0 - continue - - completion = response[0].completion - if completion is None: - bt.logging.info(f"Completion is None for UID {uid}") - scores[uid] = 0 - uid_scores_dict[uid] = 0 - continue - - bt.logging.info(f"UID {uid} response is {completion}") - image_url = completion["url"] - download_task = asyncio.create_task(self.download_image(image_url)) - messages_for_uid = uid_to_messages[uid] - if will_score_all: - score_task = template.reward.image_score(uid, image_url, self.size, messages_for_uid, self.weight) - score_tasks.append((uid, score_task)) - - download_tasks.append((uid, download_task, image_url)) - - # Wait for all download tasks to complete - for uid, download_task, image_url in download_tasks: - image = await download_task - # Log the image to wandb - self.wandb_data["images"][uid] = wandb.Image(image) - self.wandb_data["responses"][uid] = {"url": image_url} - # self.wandb_data["timestamps"][uid] = datetime.datetime.now().isoformat() - - # Await all scoring tasks concurrently - scored_responses = await asyncio.gather(*[task for _, task in score_tasks]) - - # Process the results of scoring tasks - for (uid, _), scored_response in zip(score_tasks, scored_responses): - scores[uid] = uid_scores_dict[uid] = scored_response if scored_response is not None else 0 - # self.wandb_data["scores"][uid] = scored_response + rand = random.random() + will_score_all = rand < 1/1 + bt.logging.info(f"random number = {rand}, will score all = {will_score_all}") + async with aiohttp.ClientSession() as session: + for uid, syn in query_responses: + syn = syn[0] + completion = syn.completion + if completion is None: + scores[uid] = uid_scores_dict[uid] = 0 + continue + + if syn.provider in ["OpenAI", "Stability"]: + if syn.provider == "OpenAI": + image_url = completion["url"] + bt.logging.info(f"UID {uid} response = {image_url}") + download_tasks.append((uid, asyncio.create_task(self.download_image(image_url, session)))) + else: # Stability + b64s = completion["b64s"] + bt.logging.info(f"UID {uid} responded with an image") + for b64 in b64s: + download_tasks.append((uid, asyncio.create_task(self.b64_to_image(b64)))) + + if will_score_all: + if syn.provider == "OpenAI": + score_task = template.reward.dalle_score(uid, image_url, self.size, syn.messages, self.weight) + else: + score_task = template.reward.deterministic_score(uid, syn, self.weight) + + score_tasks.append((uid, asyncio.create_task(score_task))) + + await asyncio.gather(*(dt[1] for dt in download_tasks), *(st[1] for st in score_tasks)) + + download_results = [self.process_download_result(uid, dt) for uid, dt in download_tasks] + await asyncio.gather(*download_results) + + score_results = [self.process_score_result(uid, st, scores, uid_scores_dict) for uid, st in score_tasks] + await asyncio.gather(*score_results) if uid_scores_dict != {}: - bt.logging.info(f"image_scores = {uid_scores_dict}") + bt.logging.info(f"scores = {uid_scores_dict}") + return scores, uid_scores_dict, self.wandb_data + diff --git a/validators/text_validator.py b/validators/text_validator.py index 9d0ba78e..a6e5b3f9 100644 --- a/validators/text_validator.py +++ b/validators/text_validator.py @@ -75,7 +75,7 @@ async def start_query(self, available_uids, metagraph) -> tuple[list, dict]: query_tasks = [] uid_to_question = {} # Randomly choose the provider based on specified probabilities - providers = ["OpenAI"] * 9 + ["Anthropic"] * 1 + providers = ["OpenAI"] * 5 + ["Anthropic"] * 5 self.provider = random.choice(providers) if self.provider == "Anthropic": @@ -103,7 +103,7 @@ async def start_query(self, available_uids, metagraph) -> tuple[list, dict]: def should_i_score(self): random_number = random.random() - will_score_all = random_number < 1 / 5 + will_score_all = random_number < 1 / 2 bt.logging.info(f"Random Number: {random_number}, Will score text responses: {will_score_all}") return will_score_all diff --git a/validators/weight_setter.py b/validators/weight_setter.py index aa15bc3e..4ab887a5 100644 --- a/validators/weight_setter.py +++ b/validators/weight_setter.py @@ -96,7 +96,7 @@ async def perform_synthetic_scoring_and_update_weights(self): await asyncio.sleep(10) def select_validator(self, steps_passed): - return self.text_vali # if steps_passed % 5 in (0, 1, 2) else self.image_vali + return self.image_vali if steps_passed % 5 in (0, 1, 2) else self.text_vali async def get_available_uids(self): """Get a dictionary of available UIDs and their axons asynchronously."""