import gradio as gr import random from transformers import pipeline # Load the model once when the app starts generator = pipeline('text-generation', model='distilgpt2') # Lightweight model # Predefined words to check SPECIAL_WORDS = ['weather', 'sun', 'middle', 'summer', 'heat'] def generate_circular_text_design(word): """Generate a styled design for a word by styling each letter individually.""" # Controlled randomization parameters fonts = [ "'Dosis', sans-serif", "'Josefin Sans', sans-serif", "'Orbitron', sans-serif", "'Roboto Condensed', sans-serif", "'VT323', monospace", "'Rajdhani', sans-serif", "'Anton', sans-serif", "'Caveat', cursive", "'Patrick Hand', cursive", "'Nothing You Could Do', cursive", "'Reenie Beanie', cursive", "'Patrick Hand', cursive", "'Raleway', sans-serif", "'Open Sans Condensed', sans-serif", "'Poiret One', cursive", "'Indie Flower', cursive", "'Pacifico', cursive", "'Teko', sans-serif", "'Abril Fatface', cursive", "'Gloria Hallelujah', cursive", "'Righteous', cursive", "'Annie Use Your Telescope', cursive" ] font_sizes = [17, 19, 21, 23, 25, 27] font_tops = [11, 11, 13, 13, 15, 15] letter_spacings = ["-6px", "-4px", "-3px", "-2px", "-1px", "0px", "1px", "2px"] text_shadows = [ "0px 0px 1px", "0px 0px 2px", "1px 0px 0px", "0px 0px 0px", "0px 1px 0px", "0px 2px 0px", "0px 1px 1px", "1px 1px 0px", "1px 0px 1px" ] skew_angles = [-10, -5, 0, 5, 10, 15, 20, 25, 30] # Create HTML for each letter with dynamic styling letters = list(word) styled_letters = [] for i, letter in enumerate(letters): style = { 'font-family': random.choice(fonts), 'line-height': '110%', 'font-size': f'{random.choice(font_sizes)}px', 'letter-spacing': random.choice(letter_spacings), 'text-shadow': random.choice(text_shadows), 'transform': f'skew({random.choice(skew_angles)}deg)', 'margin-top': f'{random.uniform(-0.1, 0.1):.2f}cm', 'position': 'relative', 'top': f'{random.choice(font_tops)}px', 'color': f'#{random.randint(0, 0xFFFFFF):06x}', 'display': 'inline-block', 'margin': '0 1px' } # Convert style to inline CSS style_str = '; '.join([f'{k}: {v}' for k, v in style.items()]) # Assign a unique class name for possible future reference (if needed) styled_letter = f'