File size: 1,153 Bytes
9f836f5
ab60a70
6152c1c
 
 
9f836f5
ab60a70
ed91e59
6152c1c
 
ab60a70
ed91e59
ab60a70
ed91e59
 
 
 
6152c1c
 
 
 
 
ab60a70
ed91e59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gradio as gr
from transformers import AutoModelForCausalLM
from PIL import Image
from huggingface_hub import pipeline


# Load the SquanchNastyAI model from Hugging Face Spaces
text_model = AutoModelForCausalLM.from_pretrained("or4cl3ai/SquanchNastyAI")
# Initialize the pipeline for image generation
image_pipeline = pipeline("image-generation", model="google/vit-base-patch16-384")


# Define a function to generate a text response to a prompt
def generate_text(prompt):
    response = text_model.generate(prompt, max_length=1024)[0]
    return response


# Define a function to generate an image from a prompt
def generate_image(prompt):
    image = image_pipeline(prompt)
    return image


# Create a Gradio interface for the AI model
def ai_interface(prompt):
    text_response = generate_text(prompt)
    image_response = generate_image(prompt)
    return text_response, image_response


inputs = gr.inputs.Textbox(label="Enter a prompt")
outputs = [
    gr.outputs.Textbox(label="Text Response"),
    gr.outputs.Image(label="Image Response")
]

interface = gr.Interface(fn=ai_interface, inputs=inputs, outputs=outputs)

interface.launch()