or4cl3ai commited on
Commit
ed91e59
1 Parent(s): b3495f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -17
app.py CHANGED
@@ -5,30 +5,36 @@ from huggingface_hub import pipeline
5
 
6
 
7
  # Load the SquanchNastyAI model from Hugging Face Spaces
8
- 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
  # Define a function to generate a text response to a prompt
13
- def generate_response(prompt):
14
- return model.generate(prompt, max_length=1024)[0]
 
 
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
- # Create a Gradio interface for the SquanchNastyAI model
22
- interface = gr.Interface(
23
- fn=generate_response,
24
- inputs="text",
25
- outputs=["text", "image"],
26
- components={
27
- "text": gr.Text(),
28
- "image": gr.Image(),
29
- },
30
- layout="row",
31
- )
32
-
33
- # Launch the Gradio interface
34
- interface.launch()
 
 
 
 
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()