Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,30 +5,36 @@ from huggingface_hub import pipeline
|
|
5 |
|
6 |
|
7 |
# Load the SquanchNastyAI model from Hugging Face Spaces
|
8 |
-
|
9 |
# Initialize the pipeline for image generation
|
10 |
image_pipeline = pipeline("image-generation", model="google/vit-base-patch16-384")
|
11 |
|
|
|
12 |
# Define a function to generate a text response to a prompt
|
13 |
-
def
|
14 |
-
|
|
|
|
|
15 |
|
16 |
# Define a function to generate an image from a prompt
|
17 |
def generate_image(prompt):
|
18 |
image = image_pipeline(prompt)
|
19 |
return image
|
20 |
|
21 |
-
|
22 |
-
interface
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
)
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
5 |
|
6 |
|
7 |
# Load the SquanchNastyAI model from Hugging Face Spaces
|
8 |
+
text_model = AutoModelForCausalLM.from_pretrained("or4cl3ai/SquanchNastyAI")
|
9 |
# Initialize the pipeline for image generation
|
10 |
image_pipeline = pipeline("image-generation", model="google/vit-base-patch16-384")
|
11 |
|
12 |
+
|
13 |
# Define a function to generate a text response to a prompt
|
14 |
+
def generate_text(prompt):
|
15 |
+
response = text_model.generate(prompt, max_length=1024)[0]
|
16 |
+
return response
|
17 |
+
|
18 |
|
19 |
# Define a function to generate an image from a prompt
|
20 |
def generate_image(prompt):
|
21 |
image = image_pipeline(prompt)
|
22 |
return image
|
23 |
|
24 |
+
|
25 |
+
# Create a Gradio interface for the AI model
|
26 |
+
def ai_interface(prompt):
|
27 |
+
text_response = generate_text(prompt)
|
28 |
+
image_response = generate_image(prompt)
|
29 |
+
return text_response, image_response
|
30 |
+
|
31 |
+
|
32 |
+
inputs = gr.inputs.Textbox(label="Enter a prompt")
|
33 |
+
outputs = [
|
34 |
+
gr.outputs.Textbox(label="Text Response"),
|
35 |
+
gr.outputs.Image(label="Image Response")
|
36 |
+
]
|
37 |
+
|
38 |
+
interface = gr.Interface(fn=ai_interface, inputs=inputs, outputs=outputs)
|
39 |
+
|
40 |
+
interface.launch()
|