Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
A3='FP32 (Lambat, Kualitas Terbaik)'
|
| 2 |
+
A2='FP16 (Cepat, Kualitas Baik)'
|
| 3 |
+
A1='Semua Waktu'
|
| 4 |
+
A0='secondary'
|
| 5 |
+
z='3 Bulan Terakhir'
|
| 6 |
+
y='2 Minggu Terakhir'
|
| 7 |
+
x='1 Minggu Terakhir'
|
| 8 |
+
w='%Y-%m-%d %H:%M:%S'
|
| 9 |
+
v='caidas/swin2sr-realworld-sr-x4-64-bsrgan-psnr'
|
| 10 |
+
u=ImportError
|
| 11 |
+
i=1.
|
| 12 |
+
h='utf-8'
|
| 13 |
+
g=len
|
| 14 |
+
f=open
|
| 15 |
+
V='primary'
|
| 16 |
+
U='cuda'
|
| 17 |
+
T=Exception
|
| 18 |
+
L='Total Pengunjung'
|
| 19 |
+
H='panel'
|
| 20 |
+
F='Timestamp'
|
| 21 |
+
E=True
|
| 22 |
+
D=False
|
| 23 |
+
C=print
|
| 24 |
+
B=None
|
| 25 |
+
import gradio as A,torch as G,numpy as W
|
| 26 |
+
from diffusers import DiffusionPipeline as A4
|
| 27 |
+
import random as j,time as k,os as M
|
| 28 |
+
from datetime import datetime as l,timedelta as X
|
| 29 |
+
import csv,pandas as I,threading as A5
|
| 30 |
+
from PIL import Image,ImageEnhance as A6
|
| 31 |
+
try:import psutil as N,platform as O;from transformers import Swin2SRForImageSuperResolution as Y,Swin2SRImageProcessor as m;C('β
Library tambahan (psutil, transformers) berhasil diimpor.')
|
| 32 |
+
except u:C("β Peringatan: Library 'psutil' atau 'transformers' tidak ditemukan. Fitur System Monitor & Upscaler tidak akan berfungsi.");N=B;O=B;Y=B;m=B
|
| 33 |
+
try:import google.generativeai as P;C("β
Library 'google-generativeai' berhasil diimpor.")
|
| 34 |
+
except u:C("β Peringatan: Library 'google-generativeai' tidak ditemukan. Fitur Chatbot & Prompt Enhancer tidak akan berfungsi.");P=B
|
| 35 |
+
A7='\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>RenXploit\'s Creative AI Suite</title>\n <link rel="preconnect" href="https://fonts.googleapis.com">\n <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>\n <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Fira+Code:wght@500&display=swap" rel="stylesheet">\n <script>\n function typewriterEffect(element, text, speed) {\n let i = 0;\n element.innerHTML = ""; \n const cursor = document.createElement(\'span\');\n cursor.className = \'typewriter-cursor\';\n cursor.innerHTML = \'|\';\n element.appendChild(cursor);\n function type() {\n if (i < text.length) {\n element.insertBefore(document.createTextNode(text.charAt(i)), cursor);\n i++;\n setTimeout(type, speed);\n } else {\n cursor.style.animation = \'blink 1s step-end infinite\';\n }\n }\n type();\n }\n\n document.addEventListener("DOMContentLoaded", function(event) {\n const titleElement = document.querySelector(\'#main-title h1\');\n if (titleElement) {\n const titleText = "π RenXploit\'s Creative AI Suite π";\n titleElement.textContent = "";\n setTimeout(() => typewriterEffect(titleElement, titleText, 50), 500);\n }\n \n // --- JAVASCRIPT UNTUK TRIGGER PERIODIK YANG KOMPATIBEL ---\n setInterval(() => {\n const triggerButton = document.querySelector(\'#system-info-trigger-btn button\');\n if (triggerButton) {\n triggerButton.click();\n }\n }, 5000); // Interval 5000 milidetik = 5 detik\n });\n </script>\n <style>\n :root { --primary-color: #00aaff; --primary-hover-color: #0088cc; --background-color: #0d1117; --content-background-color: #161b22; --border-color: #30363d; --text-color: #c9d1d9; --text-muted-color: #8b949e; --font-family-main: \'Inter\', sans-serif; --font-family-mono: \'Fira Code\', monospace; --border-radius: 12px; --shadow-light: 0 4px 14px 0 rgba(0, 170, 255, 0.1); --shadow-strong: 0 6px 20px 0 rgba(0, 170, 255, 0.15); }\n body, .gradio-container { font-family: var(--font-family-main); background-color: var(--background-color) !important; color: var(--text-color); }\n h1, h2, h3 { color: #ffffff; font-weight: 600; }\n #main-title h1 { font-size: 2.5em !important; font-weight: 700 !important; text-align: center; padding: 2rem 1rem; color: #ffffff; background: linear-gradient(90deg, #00aaff, #00ffaa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: inline-block; }\n #main-title .typewriter-cursor { color: var(--primary-color); font-weight: bold; }\n @keyframes blink { from, to { opacity: 1 } 50% { opacity: 0 } }\n #main-subtitle p { font-size: 1.2em !important; text-align: center; color: var(--text-muted-color); margin-top: -1.5rem !important; margin-bottom: 2rem !important; }\n .gradio-tabs { border: none !important; background-color: transparent !important; margin-bottom: 1.5rem; }\n .gradio-tabs > div[role="tablist"] { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; }\n .gradio-tabs > div[role="tablist"] > button { background-color: transparent !important; color: var(--text-muted-color) !important; border: none !important; border-bottom: 3px solid transparent !important; font-size: 1.1em !important; font-weight: 600 !important; padding: 12px 20px !important; border-radius: 8px 8px 0 0 !important; transition: all 0.3s ease; }\n .gradio-tabs > div[role="tablist"] > button:hover { background-color: var(--content-background-color) !important; color: var(--primary-color) !important; }\n .gradio-tabs > div[role="tablist"] > button.selected { color: var(--primary-color) !important; border-bottom: 3px solid var(--primary-color) !important; background-color: var(--content-background-color) !important; }\n .tabitem { background-color: transparent !important; border: none !important; padding: 0 !important; }\n .gradio-row.panel, .gradio-accordion { background-color: var(--content-background-color) !important; border: 1px solid var(--border-color) !important; border-radius: var(--border-radius) !important; padding: 24px !important; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }\n .gradio-accordion { margin-top: 1rem; }\n .gradio-button.primary { background: linear-gradient(90deg, var(--primary-color), #00c6ff) !important; color: #ffffff !important; font-weight: 600 !important; font-size: 1.1em !important; border-radius: 8px !important; border: none !important; padding: 12px 24px !important; transition: all 0.3s ease; box-shadow: var(--shadow-light); }\n .gradio-button.primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-strong); }\n .gradio-button.secondary { background-color: var(--content-background-color) !important; border: 1px solid var(--primary-color) !important; color: var(--primary-color) !important; transition: all 0.3s ease; }\n .gradio-button.secondary:hover { background-color: var(--primary-color) !important; color: #ffffff !important; }\n .gradio-textbox, .gradio-number, .gradio-image { background-color: var(--background-color) !important; border: 1px solid var(--border-color) !important; color: var(--text-color) !important; border-radius: 8px !important; }\n .gradio-textbox textarea, .gradio-number input { color: var(--text-color) !important; }\n .gradio-textbox:focus-within, .gradio-number:focus-within { border-color: var(--primary-color) !important; box-shadow: 0 0 0 2px rgba(0, 170, 255, 0.3); }\n div.info { color: var(--text-muted-color) !important; font-style: italic; }\n #gallery { border-radius: var(--border-radius) !important; overflow: hidden; border: 1px solid var(--border-color); background-color: #010409; }\n #gallery .gallery-item { transition: transform 0.3s ease, box-shadow 0.3s ease; }\n #gallery .gallery-item:hover { transform: scale(1.03); box-shadow: 0 8px 30px rgba(0, 170, 255, 0.3); }\n .loader-container { border: 1px solid var(--border-color); border-radius: var(--border-radius); padding: 30px; background: var(--content-background-color); text-align: center; overflow: hidden; }\n .loader-text { font-family: var(--font-family-mono); font-size: 1.1em; color: var(--primary-color); margin-bottom: 20px; }\n .loader-bar-container { height: 8px; background: var(--background-color); border-radius: 4px; overflow: hidden; }\n .loader-bar { width: 100%; height: 100%; background: linear-gradient(90deg, transparent, var(--primary-color), transparent); background-size: 200% 100%; animation: scan 2s linear infinite; }\n @keyframes scan { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }\n .gradio-chatbot .message { border-radius: 12px !important; box-shadow: none !important; }\n .gradio-chatbot .user { background-color: var(--primary-color) !important; color: white !important; }\n .gradio-chatbot .bot { background-color: var(--content-background-color) !important; border: 1px solid var(--border-color) !important; }\n .footer { text-align: center; margin: 2rem auto; padding: 1rem; color: var(--text-muted-color); border-top: 1px solid var(--border-color); }\n .footer b { color: var(--primary-color); }\n </style>\n</head>\n'
|
| 36 |
+
J='visitor_log.csv'
|
| 37 |
+
Z=A5.Lock()
|
| 38 |
+
K=U if G.cuda.is_available()else'cpu'
|
| 39 |
+
C(f"β‘οΈ Menggunakan device: {K.upper()}")
|
| 40 |
+
def A8():
|
| 41 |
+
if not M.path.exists(J):
|
| 42 |
+
with Z:
|
| 43 |
+
if not M.path.exists(J):
|
| 44 |
+
with f(J,mode='w',newline='',encoding=h)as A:B=csv.writer(A);B.writerow([F,'IP Address','User Agent'])
|
| 45 |
+
C(f"β
File log '{J}' berhasil dibuat.")
|
| 46 |
+
A8()
|
| 47 |
+
C('β‘οΈ Memuat model SDXL-Turbo...')
|
| 48 |
+
n=A4.from_pretrained('stabilityai/sdxl-turbo',torch_dtype=G.float16 if K==U else G.float32,variant='fp16'if K==U else B,use_safetensors=E).to(K)
|
| 49 |
+
if G.cuda.is_available():n.enable_xformers_memory_efficient_attention()
|
| 50 |
+
C('β
Model SDXL-Turbo berhasil dimuat.')
|
| 51 |
+
a=B
|
| 52 |
+
b=B
|
| 53 |
+
if Y:
|
| 54 |
+
try:C('β‘οΈ Memuat model AI Upscaler (Swin2SR)...');a=Y.from_pretrained(v).to(K);b=m.from_pretrained(v);C('β
Model AI Upscaler berhasil dimuat.')
|
| 55 |
+
except T as A9:C(f"β Gagal memuat model Upscaler: {A9}. Fitur upscale akan dinonaktifkan.")
|
| 56 |
+
class AA:
|
| 57 |
+
def __init__(A):
|
| 58 |
+
A.api_keys=[];A.is_configured=D
|
| 59 |
+
if not P:return
|
| 60 |
+
B=1
|
| 61 |
+
while E:
|
| 62 |
+
F=M.getenv(f"GEMINI_API_KEY_{B}")
|
| 63 |
+
if F:A.api_keys.append(F);B+=1
|
| 64 |
+
else:break
|
| 65 |
+
if A.api_keys:C(f"β
Berhasil memuat {g(A.api_keys)} API Key Gemini. Sistem rotasi aktif.");A.is_configured=E
|
| 66 |
+
else:C('β PERINGATAN: Tidak ada API Key Gemini yang ditemukan. Fitur AI Chat & Prompt Enhancer tidak akan berfungsi.')
|
| 67 |
+
def chat(A,message,history,system_prompt=B):
|
| 68 |
+
D=system_prompt;B=message
|
| 69 |
+
if not A.is_configured:return'Maaf, fitur ini tidak terkonfigurasi karena tidak ada API Key.'
|
| 70 |
+
try:
|
| 71 |
+
F=j.choice(A.api_keys);P.configure(api_key=F);G=P.GenerativeModel('gemini-2.5-flash');E=B
|
| 72 |
+
if D:E=f"{D}\n\nUser query: {B}"
|
| 73 |
+
H=G.generate_content(E);return H.text
|
| 74 |
+
except T as I:C(f"β Terjadi error pada API Key Gemini: {I}");return'Terjadi kesalahan saat menghubungi API AI. Mungkin salah satu API Key tidak valid atau ada masalah jaringan. Silakan coba lagi.'
|
| 75 |
+
Q=AA()
|
| 76 |
+
def AB(request):
|
| 77 |
+
D='N/A';A=request;E=l.now().strftime(w);B=A.client.host if A else D;F=A.headers.get('user-agent','Unknown')if A else D
|
| 78 |
+
with Z:
|
| 79 |
+
with f(J,mode='a',newline='',encoding=h)as G:H=csv.writer(G);H.writerow([E,B,F])
|
| 80 |
+
C(f"β
Pengunjung baru tercatat: IP {B}")
|
| 81 |
+
def AC(prompt,negative_prompt,steps,seed,num_images):
|
| 82 |
+
C=prompt;B=seed
|
| 83 |
+
if not C:raise A.Error('Prompt tidak boleh kosong!')
|
| 84 |
+
if B==-1:B=j.randint(0,2**32-1)
|
| 85 |
+
D=G.manual_seed(B);E=n(prompt=C,negative_prompt=negative_prompt,generator=D,num_inference_steps=steps,guidance_scale=.0,num_images_per_prompt=num_images).images;return E,B
|
| 86 |
+
def AD(prompt,negative_prompt,steps,seed,num_images):yield(A.update(visible=D),A.update(visible=E),A.update(interactive=D),A.update(visible=D));B=k.time();C,F=AC(prompt,negative_prompt,steps,int(seed),int(num_images));G=k.time();H=G-B;I=f"Seed yang digunakan: {F}\nTotal waktu generasi: {H:.2f} detik";yield(A.update(value=C,visible=E),A.update(visible=D),A.update(interactive=E),A.update(value=I,visible=E))
|
| 87 |
+
def AE(name,email,message):
|
| 88 |
+
B=message
|
| 89 |
+
if not name or not B:A.Warning('Nama dan Pesan tidak boleh kosong!');return A.update(visible=D)
|
| 90 |
+
F=l.now().strftime(w);G=f"""--- Laporan Baru ({F}) ---
|
| 91 |
+
Nama: {name}
|
| 92 |
+
Email: {email}
|
| 93 |
+
Pesan: {B}
|
| 94 |
+
|
| 95 |
+
"""
|
| 96 |
+
with f('reports.log','a',encoding=h)as H:H.write(G)
|
| 97 |
+
C('β
Laporan baru telah disimpan ke reports.log');return A.update(value='β
Terima kasih! Laporan Anda telah kami terima.',visible=E)
|
| 98 |
+
def c(time_filter):
|
| 99 |
+
K='## π 0';G=time_filter
|
| 100 |
+
try:
|
| 101 |
+
with Z:
|
| 102 |
+
if not M.path.exists(J)or M.path.getsize(J)<10:return K,I.DataFrame({F:[],L:[]})
|
| 103 |
+
A=I.read_csv(J)
|
| 104 |
+
if A.empty:return K,I.DataFrame({F:[],L:[]})
|
| 105 |
+
A[F]=I.to_datetime(A[F],errors='coerce');A.dropna(subset=[F],inplace=E)
|
| 106 |
+
if A.empty:return K,I.DataFrame({F:[],L:[]})
|
| 107 |
+
P=g(A);N=f"## π {P:,}";A[L]=W.arange(1,g(A)+1);H=I.to_datetime('now',utc=E).tz_localize(B);A[F]=A[F].dt.tz_localize(B)
|
| 108 |
+
if G==x:D=A[A[F]>=H-X(weeks=1)]
|
| 109 |
+
elif G==y:D=A[A[F]>=H-X(weeks=2)]
|
| 110 |
+
elif G==z:D=A[A[F]>=H-X(days=90)]
|
| 111 |
+
else:D=A
|
| 112 |
+
if D.empty:return N,I.DataFrame({F:[],L:[]})
|
| 113 |
+
return N,D
|
| 114 |
+
except T as Q:O=f"Error saat memperbarui monitor: {Q}";C(f"β {O}");return f"## β οΈ Error",I.DataFrame({'Error':[O]})
|
| 115 |
+
def AF(simple_prompt):
|
| 116 |
+
B=simple_prompt
|
| 117 |
+
if not B:A.Warning('Tolong masukkan ide Anda terlebih dahulu.');return''
|
| 118 |
+
if not Q.is_configured:A.Error('Fitur Prompt Enhancer tidak aktif karena API Key Gemini tidak diatur.');return'Fitur tidak aktif.'
|
| 119 |
+
C='Anda adalah seorang ahli prompt engineering untuk model AI text-to-image seperti Stable Diffusion. Tugas Anda adalah mengubah ide sederhana dari pengguna menjadi prompt yang kaya, deskriptif, dan artistik. Fokus pada detail visual: subjek, setting, pencahayaan (cinematic lighting, soft light, dll), gaya seni (photorealistic, anime style, oil painting, dll), komposisi, dan kualitas (hyperdetailed, 4K, masterpiece, trending on artstation). Hasilkan HANYA prompt-nya saja dalam format teks panjang, tanpa penjelasan atau kalimat pembuka/penutup.';yield'π§ AI sedang meracik prompt ajaib untuk Anda...';D=Q.chat(B,[],system_prompt=C);yield D
|
| 120 |
+
def AG(image_to_upscale,clarity_strength):
|
| 121 |
+
H=image_to_upscale;F=clarity_strength
|
| 122 |
+
if H is B:raise A.Error('Silakan unggah gambar terlebih dahulu.')
|
| 123 |
+
if a is B or b is B:raise A.Error('Fitur Upscaler tidak aktif karena model gagal dimuat. Periksa log saat startup.')
|
| 124 |
+
yield(B,'π Memproses peningkatan resolusi 4x oleh AI...')
|
| 125 |
+
try:
|
| 126 |
+
with G.no_grad():J=b(H,return_tensors='pt').to(K);L=a(**J);E=L.reconstruction.data.squeeze().float().cpu().clamp_(0,1).numpy();E=W.moveaxis(E,source=0,destination=-1);E=(E*255.).round().astype(W.uint8);D=Image.fromarray(E)
|
| 127 |
+
if F>i:yield(D,f"β¨ Menerapkan peningkatan kejernihan (Strength: {F:.2f})...");M=A6.Sharpness(D);D=M.enhance(F)
|
| 128 |
+
yield(D,f"β
Gambar berhasil ditingkatkan! Resolusi akhir: {D.width}x{D.height}px.")
|
| 129 |
+
except T as I:C(f"β Error saat upscaling: {I}");yield(B,f"β οΈ Terjadi error saat upscaling: {I}")
|
| 130 |
+
def o():
|
| 131 |
+
if not N or not O:return'Informasi sistem tidak tersedia (library `psutil` tidak ditemukan).'
|
| 132 |
+
D=N.cpu_percent(interval=B);A=N.virtual_memory();C='Tidak terdeteksi (PyTorch tidak menemukan CUDA)'
|
| 133 |
+
if G.cuda.is_available():E=G.cuda.get_device_name(0);F=G.cuda.memory_allocated(0)/1024**3;H=G.cuda.get_device_properties(0).total_memory/1024**3;C=f"**GPU:** `{E}`\n**VRAM Terpakai:** `{F:.2f} GB / {H:.2f} GB`"
|
| 134 |
+
I=f"**Platform:** `{O.system()} {O.release()}`";return f"**CPU Terpakai:** `{D:.1f}%`\n**RAM Terpakai:** `{A.percent:.1f}% ({A.used/1024**3:.2f} GB / {A.total/1024**3:.2f} GB)`\n{C}\n---\n{I}"
|
| 135 |
+
with A.Blocks(theme=A.themes.Base(),head=A7)as R:
|
| 136 |
+
A.Markdown("# π RenXploit's Creative AI Suite π",elem_id='main-title');A.Markdown('Sebuah platform lengkap untuk kreativitas Anda, ditenagai oleh AI.',elem_id='main-subtitle')
|
| 137 |
+
with A.Tabs()as AH:
|
| 138 |
+
with A.TabItem('π¨ Image Generator',id=0):
|
| 139 |
+
with A.Row(variant=H,equal_height=D):
|
| 140 |
+
with A.Column(scale=1):
|
| 141 |
+
A.Markdown('### π **Masukan Perintah Anda**');p=A.Textbox(label='Prompt',placeholder='Contoh: Cinematic photo, seekor rubah merah...',lines=3,info='Jadilah sangat spesifik! Atau gunakan Prompt Enhancer.');AI=A.Textbox(label='Prompt Negatif',placeholder='Contoh: blurry, low quality, bad hands...',lines=2,info='Hal-hal yang TIDAK Anda inginkan.');AJ=A.Slider(minimum=1,maximum=8,value=2,step=1,label='Jumlah Gambar');q=A.Button('β¨ Hasilkan Gambar!',variant=V)
|
| 142 |
+
with A.Accordion('βοΈ Opsi Lanjutan',open=D):
|
| 143 |
+
AK=A.Slider(minimum=1,maximum=5,value=2,step=1,label='Langkah Iterasi (Kualitas vs Kecepatan)')
|
| 144 |
+
with A.Row():r=A.Number(label='Seed',value=-1,precision=0,info='Gunakan -1 untuk acak.');AL=A.Button('π² Acak',variant=A0)
|
| 145 |
+
with A.Column(scale=2):A.Markdown('### πΌοΈ **Hasil Generasi**');AM=A.Gallery(label='Hasil Gambar',show_label=D,elem_id='gallery',columns=2,object_fit='contain',height='auto');AN=A.HTML(visible=D);AO=A.Textbox(label='Informasi Generasi',visible=D,interactive=D,lines=2)
|
| 146 |
+
with A.TabItem('π¬ Chat with AI',id=1):
|
| 147 |
+
with A.Row(variant=H):
|
| 148 |
+
with A.Column():
|
| 149 |
+
A.Markdown('### π€ **Asisten AI Flood**')
|
| 150 |
+
if not Q.is_configured:A.Warning('Fitur Chatbot dinonaktifkan. API Key Gemini tidak terkonfigurasi.')
|
| 151 |
+
else:A.ChatInterface(Q.chat,chatbot=A.Chatbot(height=500,label='Flood AI',value=[(B,'Halo! Saya adalah asisten AI dari RenXploit. Ada yang bisa saya bantu?')]),title=B,description='Tanyakan apa saja!',examples=['Apa itu SDXL-Turbo?','Buatkan saya puisi tentang AI','Jelaskan konsep lubang hitam dengan sederhana'])
|
| 152 |
+
with A.TabItem('β¨ Prompt Enhancer',id=2):
|
| 153 |
+
with A.Row(variant=H):
|
| 154 |
+
with A.Column():
|
| 155 |
+
A.Markdown('### πͺ **Ubah Ide Jadi Prompt Ajaib**\nCukup tulis ide sederhana, dan biarkan AI menyempurnakannya menjadi prompt yang detail dan artistik.');AP=A.Textbox(label='Ide Sederhana Anda',placeholder='Contoh: seekor astronot di hutan alien',lines=3);AQ=A.Button('Buat Prompt Ajaib!',variant=V);s=A.Textbox(label='Prompt yang Disempurnakan',lines=5,interactive=E,show_copy_button=E)
|
| 156 |
+
with A.Row():AR=A.Button('β‘οΈ Kirim & Pindah ke Generator')
|
| 157 |
+
with A.TabItem('π AI Image Upscaler',id=3):
|
| 158 |
+
with A.Row(variant=H,equal_height=D):
|
| 159 |
+
with A.Column():A.Markdown('### **Tingkatkan Resolusi Gambar**\nUnggah gambar untuk meningkatkan kualitas dan ukurannya hingga 4x lipat menggunakan AI.');AS=A.Image(type='pil',label='Unggah Gambar Anda di Sini');AT=A.Slider(minimum=i,maximum=3.,value=i,step=.1,label='Tingkat Peningkatan Kejernihan',info='Setelah di-upscale 4x, atur kejernihan gambar di sini. 1.0 = Tanpa efek.');AU=A.Button('Tingkatkan Resolusi!',variant=V)
|
| 160 |
+
with A.Column():A.Markdown('### **Hasil Peningkatan Resolusi**');AV=A.Image(label='Gambar Hasil Upscale',interactive=D);AW=A.Markdown('Status: Menunggu gambar...')
|
| 161 |
+
with A.TabItem('π Visitor Monitor',id=4):
|
| 162 |
+
with A.Row(variant=H):
|
| 163 |
+
with A.Column():
|
| 164 |
+
A.Markdown('### π **Live Visitor Monitor**\nPantau jumlah total pengunjung aplikasi Anda secara real-time.')
|
| 165 |
+
with A.Row():
|
| 166 |
+
with A.Column(scale=3):d=A.Markdown('## π Memuat data...')
|
| 167 |
+
with A.Column(scale=2):S=A.Radio([A1,x,y,z],label='Tampilkan data untuk',value=A1);AX=A.Button('π Segarkan Manual',variant=A0)
|
| 168 |
+
e=A.LinePlot(x=F,y=L,title='Grafik Pertumbuhan Pengunjung',tooltip=[F,L],height=500,interactive=E)
|
| 169 |
+
with A.TabItem('βοΈ System & Settings',id=5):
|
| 170 |
+
with A.Row(variant=H):
|
| 171 |
+
with A.Column():A.Markdown('### **Live System Monitor**');t=A.Markdown('Memuat info sistem...');AY=A.Button('Trigger System Info',visible=D,elem_id='system-info-trigger-btn')
|
| 172 |
+
with A.Column():
|
| 173 |
+
A.Markdown('### **Pengaturan Aplikasi**')
|
| 174 |
+
with A.Accordion('Kualitas Model',open=E):A.Radio([A2,A3],value=A2 if K==U else A3,label='Presisi Model Generator',interactive=D,info='Terkunci. Pengaturan ini ditentukan saat aplikasi dimulai berdasarkan ketersediaan GPU Anda.')
|
| 175 |
+
with A.TabItem('π‘ Panduan Prompting',id=6):
|
| 176 |
+
with A.Row(variant=H):A.Markdown('## Cara Menjadi "Art Director" yang Hebat untuk AI...')
|
| 177 |
+
with A.TabItem('π Blog & Updates',id=7):
|
| 178 |
+
with A.Row(variant=H):A.Markdown("### Perkembangan Terbaru dari RenXploit's AI Suite\n- **v2.4 (Pembaruan Terkini):** Upscaler di-upgrade dengan kontrol kejernihan, Visitor Monitor diperbaiki, dan UI Settings diperjelas.\n- **v2.3:** Perbaikan bug kritis untuk kompatibilitas dengan berbagai versi Gradio.\n- **v2.2:** Perbaikan bug untuk kompatibilitas Gradio.\n- **v2.1:** Menambahkan **Prompt Enhancer**, **AI Image Upscaler**, dan **Live System Monitor**.\n- **v2.0:** Perombakan Desain Total.\n- **Rencana Berikutnya:** Menjajaki model generator gambar yang berbeda dan fitur Inpainting/Outpainting. Nantikan!")
|
| 179 |
+
with A.TabItem('βΉοΈ About & Support',id=8):
|
| 180 |
+
with A.Row(variant=H):
|
| 181 |
+
with A.Column():
|
| 182 |
+
A.Markdown('### Tentang Proyek dan Dukungan')
|
| 183 |
+
with A.Accordion("Tentang RenXploit's Creative AI Suite",open=E):A.Markdown("**RenXploit's Creative AI Suite** adalah proyek pribadi yang dibuat untuk mengeksplorasi kemampuan AI generatif dalam sebuah antarmuka yang mudah digunakan.\n **Bagian ini belum saya kerjakan dengan selesai** jadi jika anda ingin komplain atau ada hal apapun itu bisa report ke saya lewat website portofolio saya dengan url: https://ngoprek.xyz/contact")
|
| 184 |
+
with A.Accordion('Laporkan Masalah atau Beri Masukan'):AZ=A.Textbox(label='Nama Anda');Aa=A.Textbox(label='Email Anda (Opsional)');Ab=A.Textbox(label='Pesan Anda',lines=5,placeholder='Jelaskan masalah yang Anda temui atau ide yang Anda miliki...');Ac=A.Button('Kirim Laporan',variant=V);Ad=A.Markdown(visible=D)
|
| 185 |
+
A.Markdown("---\n<div class='footer'><p>Dibuat dengan β€οΈ oleh <b>RenXploit</b>.</p></div>",elem_classes='footer');AL.click(lambda:-1,outputs=r);q.click(fn=AD,inputs=[p,AI,AK,r,AJ],outputs=[AM,AN,q,AO]);Ac.click(fn=AE,inputs=[AZ,Aa,Ab],outputs=[Ad]);R.load(AB,inputs=B,outputs=B);R.load(fn=c,inputs=[S],outputs=[d,e]);AX.click(fn=c,inputs=[S],outputs=[d,e]);S.change(fn=c,inputs=[S],outputs=[d,e]);AQ.click(fn=AF,inputs=[AP],outputs=[s]);AR.click(fn=lambda prompt:(prompt,A.Tabs(selected=0)),inputs=[s],outputs=[p,AH]);AU.click(fn=AG,inputs=[AS,AT],outputs=[AV,AW]);AY.click(fn=o,inputs=B,outputs=t);R.load(fn=o,inputs=B,outputs=t)
|
| 186 |
+
if __name__=='__main__':R.launch(debug=E)
|