Spaces:
Configuration error
Configuration error
Rename ultimate_ai_app to ultimate_ai_app_final.py
Browse files
ultimate_ai_app β ultimate_ai_app_final.py
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
# ===========================
|
| 2 |
-
# Ultimate AI App -
|
| 3 |
# ===========================
|
| 4 |
|
| 5 |
# Required Libraries:
|
| 6 |
-
# pip install diffusers transformers torch TTS moviepy pillow
|
| 7 |
|
| 8 |
import torch
|
| 9 |
from diffusers import StableDiffusionPipeline
|
|
@@ -12,13 +12,20 @@ from transformers import pipeline
|
|
| 12 |
from moviepy.editor import ImageSequenceClip
|
| 13 |
import numpy as np
|
| 14 |
from PIL import Image
|
| 15 |
-
import tkinter as tk
|
| 16 |
-
from tkinter import simpledialog, messagebox
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
#
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def generate_image(prompt, save_path="generated_image.png"):
|
|
|
|
| 22 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 23 |
"runwayml/stable-diffusion-v1-5",
|
| 24 |
torch_dtype=torch.float16
|
|
@@ -27,19 +34,33 @@ def generate_image(prompt, save_path="generated_image.png"):
|
|
| 27 |
pipe = pipe.to(device)
|
| 28 |
image = pipe(prompt).images[0]
|
| 29 |
image.save(save_path)
|
| 30 |
-
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
def generate_voice(text, save_path="generated_voice.wav"):
|
|
|
|
| 33 |
tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=True, gpu=torch.cuda.is_available())
|
| 34 |
tts.tts_to_file(text=text, file_path=save_path)
|
| 35 |
-
|
| 36 |
|
|
|
|
|
|
|
|
|
|
| 37 |
def generate_text(prompt, max_length=100):
|
|
|
|
| 38 |
generator = pipeline('text-generation', model='gpt2')
|
| 39 |
result = generator(prompt, max_length=max_length, num_return_sequences=1)
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
def generate_video(prompt, num_frames=10, save_path="generated_video.mp4"):
|
|
|
|
| 43 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 44 |
"runwayml/stable-diffusion-v1-5",
|
| 45 |
torch_dtype=torch.float16
|
|
@@ -54,50 +75,17 @@ def generate_video(prompt, num_frames=10, save_path="generated_video.mp4"):
|
|
| 54 |
|
| 55 |
clip = ImageSequenceClip([np.array(frame) for frame in frames], fps=2)
|
| 56 |
clip.write_videofile(save_path)
|
| 57 |
-
|
| 58 |
|
| 59 |
-
#
|
| 60 |
-
#
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
root.geometry("400x350")
|
| 65 |
-
|
| 66 |
-
tk.Label(root, text="Ultimate AI App", font=("Arial", 20, "bold")).pack(pady=10)
|
| 67 |
-
|
| 68 |
-
# Image Button
|
| 69 |
-
def image_button():
|
| 70 |
-
prompt = simpledialog.askstring("Image Prompt", "Enter prompt for image generation:")
|
| 71 |
-
if prompt:
|
| 72 |
-
generate_image(prompt)
|
| 73 |
-
|
| 74 |
-
tk.Button(root, text="Generate Image", width=30, command=image_button).pack(pady=10)
|
| 75 |
-
|
| 76 |
-
# Voice Button
|
| 77 |
-
def voice_button():
|
| 78 |
-
text = simpledialog.askstring("Voice Text", "Enter text for voice generation:")
|
| 79 |
-
if text:
|
| 80 |
-
generate_voice(text)
|
| 81 |
-
|
| 82 |
-
tk.Button(root, text="Generate Voice", width=30, command=voice_button).pack(pady=10)
|
| 83 |
-
|
| 84 |
-
# Text Button
|
| 85 |
-
def text_button():
|
| 86 |
-
prompt = simpledialog.askstring("Text Prompt", "Enter prompt for text generation:")
|
| 87 |
-
if prompt:
|
| 88 |
-
generate_text(prompt)
|
| 89 |
-
|
| 90 |
-
tk.Button(root, text="Generate Text", width=30, command=text_button).pack(pady=10)
|
| 91 |
-
|
| 92 |
-
# Video Button
|
| 93 |
-
def video_button():
|
| 94 |
-
prompt = simpledialog.askstring("Video Prompt", "Enter prompt for video generation:")
|
| 95 |
-
if prompt:
|
| 96 |
-
generate_video(prompt)
|
| 97 |
-
|
| 98 |
-
tk.Button(root, text="Generate Video", width=30, command=video_button).pack(pady=10)
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
|
|
|
| 1 |
# ===========================
|
| 2 |
+
# Ultimate AI App - Final Zero Interaction
|
| 3 |
# ===========================
|
| 4 |
|
| 5 |
# Required Libraries:
|
| 6 |
+
# pip install diffusers transformers torch TTS moviepy pillow
|
| 7 |
|
| 8 |
import torch
|
| 9 |
from diffusers import StableDiffusionPipeline
|
|
|
|
| 12 |
from moviepy.editor import ImageSequenceClip
|
| 13 |
import numpy as np
|
| 14 |
from PIL import Image
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# ===========================
|
| 17 |
+
# DEFAULT PROMPTS
|
| 18 |
+
# ===========================
|
| 19 |
+
DEFAULT_IMAGE_PROMPT = "3D, 4k, cinematic landscape, highly detailed"
|
| 20 |
+
DEFAULT_VOICE_TEXT = "Hello! This is a fully automatic AI generation test."
|
| 21 |
+
DEFAULT_TEXT_PROMPT = "Once upon a time in a futuristic world, AI created wonders."
|
| 22 |
+
DEFAULT_VIDEO_PROMPT = "Fantasy landscape, cinematic, 4k"
|
| 23 |
+
|
| 24 |
+
# ===========================
|
| 25 |
+
# IMAGE GENERATION
|
| 26 |
+
# ===========================
|
| 27 |
def generate_image(prompt, save_path="generated_image.png"):
|
| 28 |
+
print("Generating image...")
|
| 29 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 30 |
"runwayml/stable-diffusion-v1-5",
|
| 31 |
torch_dtype=torch.float16
|
|
|
|
| 34 |
pipe = pipe.to(device)
|
| 35 |
image = pipe(prompt).images[0]
|
| 36 |
image.save(save_path)
|
| 37 |
+
print(f"β
Image saved as {save_path}")
|
| 38 |
|
| 39 |
+
# ===========================
|
| 40 |
+
# VOICE GENERATION
|
| 41 |
+
# ===========================
|
| 42 |
def generate_voice(text, save_path="generated_voice.wav"):
|
| 43 |
+
print("Generating voice...")
|
| 44 |
tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=True, gpu=torch.cuda.is_available())
|
| 45 |
tts.tts_to_file(text=text, file_path=save_path)
|
| 46 |
+
print(f"β
Voice saved as {save_path}")
|
| 47 |
|
| 48 |
+
# ===========================
|
| 49 |
+
# TEXT GENERATION
|
| 50 |
+
# ===========================
|
| 51 |
def generate_text(prompt, max_length=100):
|
| 52 |
+
print("Generating text...")
|
| 53 |
generator = pipeline('text-generation', model='gpt2')
|
| 54 |
result = generator(prompt, max_length=max_length, num_return_sequences=1)
|
| 55 |
+
with open("generated_text.txt", "w", encoding="utf-8") as f:
|
| 56 |
+
f.write(result[0]['generated_text'])
|
| 57 |
+
print(f"β
Text saved as generated_text.txt")
|
| 58 |
|
| 59 |
+
# ===========================
|
| 60 |
+
# VIDEO GENERATION
|
| 61 |
+
# ===========================
|
| 62 |
def generate_video(prompt, num_frames=10, save_path="generated_video.mp4"):
|
| 63 |
+
print("Generating video...")
|
| 64 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 65 |
"runwayml/stable-diffusion-v1-5",
|
| 66 |
torch_dtype=torch.float16
|
|
|
|
| 75 |
|
| 76 |
clip = ImageSequenceClip([np.array(frame) for frame in frames], fps=2)
|
| 77 |
clip.write_videofile(save_path)
|
| 78 |
+
print(f"β
Video saved as {save_path}")
|
| 79 |
|
| 80 |
+
# ===========================
|
| 81 |
+
# MAIN - ZERO INTERACTION
|
| 82 |
+
# ===========================
|
| 83 |
+
if __name__ == "__main__":
|
| 84 |
+
print("=== Ultimate AI App - Final Zero Interaction ===\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
+
generate_image(DEFAULT_IMAGE_PROMPT)
|
| 87 |
+
generate_voice(DEFAULT_VOICE_TEXT)
|
| 88 |
+
generate_text(DEFAULT_TEXT_PROMPT)
|
| 89 |
+
generate_video(DEFAULT_VIDEO_PROMPT)
|
| 90 |
|
| 91 |
+
print("\nπ All tasks completed! All files are saved in this folder.")
|