CryptoBootz commited on
Commit
3e24e33
·
verified ·
1 Parent(s): 0d70938

Delete alpacabot(Backup).py

Browse files
Files changed (1) hide show
  1. alpacabot(Backup).py +0 -166
alpacabot(Backup).py DELETED
@@ -1,166 +0,0 @@
1
- from telegram import InputMediaPhoto
2
-
3
- import os
4
- import base64
5
- import random
6
- from datetime import datetime
7
- import requests
8
- from io import BytesIO
9
- from telegram import Update
10
- from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
11
-
12
- BOT_TOKEN = "7584662674:AAGO3YzvG6-bG6nvvBAc_r1Nmr0D8JsUSfY"
13
- A1111_URL = "http://127.0.0.1:7860"
14
-
15
- animal_loras = [
16
- ("daniml_V2_alpaca", 0.5),
17
- ("daniml_V2_badger", 0.5),
18
- ("daniml_V2_fox", 0.5),
19
- ("daniml_V2_monkey", 0.5),
20
- ("daniml_V2_pig", 0.5),
21
- ("daniml_V2_rat", 0.5),
22
- ]
23
-
24
- style_traits = {
25
- "daniml_V2_gangsterV2": ["black hoodie (hood down)", "sweatpants", "gold chain", "aviators"],
26
- "daniml_V2_cryptonerdV2": ["khakis", "crypto hoodie", "vr headset", "smartwatch", "coins"],
27
- "daniml_V2_samurai": ["samurai robe", "katana", "shoulder armor", "forearm wrap"],
28
- "daniml_V2_Astronaut": ["astronaut suit"],
29
- "daniml_V2_hazmat": ["hazmat suit", "cyan biohazard symbol"],
30
- "daniml_V2_mech": ["mech suit"],
31
- "daniml_V2_lowpoly": ["low poly"]
32
- }
33
-
34
- style_loras = [
35
- ("daniml_V2_cryptonerdV2", 0.8),
36
- ("daniml_V2_gangsterV2", 0.8),
37
- ("daniml_V2_samurai", 0.8),
38
- ("daniml_V2_Astronaut", 0.8),
39
- ("daniml_V2_lowpoly", 0.8),
40
- ("daniml_V2_hazmat", 0.8),
41
- ("daniml_V2_mech", 0.65),
42
- ]
43
-
44
- background_lora = ("daniml_background", 0.2)
45
-
46
- prompt_buckets = [
47
- "alley, cracked pavement, graffiti wall, neon kanji signs",
48
- "rooftop, vents, loose wires, neon graffiti, skyline haze",
49
- "tunnel, cracked tiles, green neon lighting, graffiti everywhere",
50
- "alley wall, layered street art, magenta neon glow, wet ground",
51
- "rooftop, rusted pipes, green haze, cracked concrete",
52
- "alley, vending machine glow, crumbling walls, neon posters",
53
- "side street, cracked cement, glowing kanji signs, mist and trash",
54
- "alley, graffiti wall both sides, purple lighting, puddles",
55
- "Tokyo alley, glowing pink signage, broken pavement, foggy atmosphere",
56
- ]
57
-
58
- async def styles(update: Update, context: ContextTypes.DEFAULT_TYPE):
59
- await update.message.reply_text(
60
- "🧬 Available DANIML Styles:\n"
61
- "- Gangster\n"
62
- "- Crypto Nerd\n"
63
- "- Samurai\n"
64
- "- Astronaut\n"
65
- "- Hazmat\n"
66
- "- Mech Pilot\n"
67
- "- Low Poly"
68
- )
69
-
70
- async def animals(update: Update, context: ContextTypes.DEFAULT_TYPE):
71
- await update.message.reply_text(
72
- "🦙 Supported Animals:\n"
73
- "- Alpaca\n"
74
- "- Badger\n"
75
- "- Fox\n"
76
- "- Monkey\n"
77
- "- Pig\n"
78
- "- Rat"
79
- )
80
-
81
- def build_prompt(animal_lora, animal_weight, style_lora, style_weight):
82
- background_prompt = random.choice(prompt_buckets)
83
- lora_string = f"<lora:{background_lora[0]}:{background_lora[1]}> <lora:{animal_lora}:{animal_weight}>"
84
-
85
- trait_description = ""
86
- if style_lora:
87
- lora_string += f" <lora:{style_lora}:{style_weight}>"
88
- trait_pool = style_traits.get(style_lora, [])
89
- selected_traits = trait_pool # use all traits as core traits
90
- trait_description = ", ".join(selected_traits)
91
-
92
- animal_name = animal_lora.replace("daniml_V2_", "")
93
- full_prompt = f"{lora_string} cyberpunk anthropomorphic {animal_name}, {trait_description}, {background_prompt}, gritty neon lighting"
94
- return full_prompt
95
-
96
- async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
97
- await update.message.reply_text(
98
- "Welcome to DANIML Gen 🦙🔌\n\n"
99
- "Your gateway to cyberpunk animal PFPs — each one AI-crafted, neon-lit, and ready to mint.\n\n"
100
- "Type /gen to roll the dice.\n"
101
- "Type /alpaca if you know what’s good.\n\n"
102
- "Drip is eternal. Mint your inner animal.⚡"
103
- )
104
-
105
- async def generate_image(update: Update, context: ContextTypes.DEFAULT_TYPE, animal_override=None):
106
- try:
107
- await update.message.reply_text("🛠 Generating your DANIML image set... please wait.")
108
- animal_lora, animal_weight = random.choice(animal_loras) if not animal_override else (animal_override, 0.4)
109
- style_lora, style_weight = random.choice(style_loras)
110
- full_prompt_1 = build_prompt(animal_lora, animal_weight, style_lora, style_weight)
111
- full_prompt_2 = build_prompt(animal_lora, animal_weight, style_lora, style_weight)
112
- print(f'Prompt 1: {full_prompt_1}')
113
- print(f'Prompt 2: {full_prompt_2}')
114
- media_group = []
115
- files = []
116
- for i, prompt in enumerate([full_prompt_1, full_prompt_2]):
117
- print(f"[DEBUG] Sending to A1111 at {datetime.now()} - Prompt {i+1}")
118
- print(prompt)
119
- payload = {
120
- "prompt": prompt,
121
- "steps": 30,
122
- "batch_size": 1,
123
- "n_iter": 1,
124
- "width": 768,
125
- "height": 768,
126
- }
127
- res = requests.post(f"{A1111_URL}/sdapi/v1/txt2img", json=payload)
128
- res.raise_for_status()
129
- images = res.json().get("images", [])
130
- if not images or not isinstance(images[0], str):
131
- await update.message.reply_text("Unexpected image format returned.")
132
- return
133
- image_base64 = images[0]
134
- if image_base64.startswith("data:image"):
135
- image_base64 = image_base64.split(",", 1)[1]
136
- img_data = base64.b64decode(image_base64)
137
- filename = f"output_{i}.png"
138
- with open(filename, "wb") as f:
139
- f.write(img_data)
140
- f = open(filename, "rb")
141
- files.append(f)
142
- media_group.append(InputMediaPhoto(f))
143
- try:
144
- await update.message.reply_media_group(media_group)
145
- except Exception as e:
146
- await update.message.reply_text(f"Send error: {e}")
147
- for f in files:
148
- f.close()
149
- except Exception as e:
150
- await update.message.reply_text(f"Error: {e}")
151
-
152
- async def gen(update: Update, context: ContextTypes.DEFAULT_TYPE):
153
- await generate_image(update, context)
154
-
155
- async def alpaca(update: Update, context: ContextTypes.DEFAULT_TYPE):
156
- await generate_image(update, context, "daniml_V2_alpaca")
157
- app = ApplicationBuilder().token(BOT_TOKEN).build()
158
- app.add_handler(CommandHandler("gen", gen))
159
- app.add_handler(CommandHandler("alpaca", alpaca))
160
- app.add_handler(CommandHandler("start", start))
161
- app.add_handler(CommandHandler("styles", styles))
162
- app.add_handler(CommandHandler("animals", animals))
163
-
164
-
165
- print("Bot is running...")
166
- app.run_polling()