voidDescriptor commited on
Commit
401e2db
1 Parent(s): 3afe13a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -6
app.py CHANGED
@@ -1,9 +1,15 @@
1
- # Import the necessary library for creating the interface
2
  import gradio as gr
3
-
4
- # Import the pipeline function from the transformers library to load the model
5
  from transformers import pipeline
6
 
 
 
 
 
 
 
 
 
7
  # Define a function to apply regex choices to the prompt text
8
  def apply_regex_choices(text):
9
  import re # Import the regular expressions module
@@ -31,8 +37,8 @@ prompt_template = """
31
  Create a GIF of a 'Technical Difficulties' television program interruption. The scene should show colored glitchy and typical 'technical difficulties' cable interruptions, (using|with) demonic symbols glitching out along with the colors of the usual 'tech difficulties' broadcasts. The setting should be (an older|a vintage) tv cable broadcast signal interruption. The style should be a realistic cable interruption interlaced with (demonic imagery|dark symbols) glitching out along with the typical color page of interruption in connection. The GIF should last for 1 second.
32
  """
33
 
34
- # Create a Gradio interface
35
- iface = gr.Interface(
36
  fn=generate_gif, # The function to call when the user interacts with the interface
37
  inputs=gr.Textbox(lines=10, placeholder="Enter your custom prompt here or use the default template", value=prompt_template), # Input textbox for the prompt
38
  outputs="file", # Output will be a file (the generated GIF)
@@ -44,6 +50,23 @@ iface = gr.Interface(
44
  ]
45
  )
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  # Launch the Gradio interface
48
- iface.launch()
 
49
 
 
1
+ # Import the necessary libraries for creating the interface
2
  import gradio as gr
 
 
3
  from transformers import pipeline
4
 
5
+ # Verify model loading
6
+ def verify_model():
7
+ try:
8
+ gif_generator = pipeline('text-to-video', model='hotshotco/Hotshot-XL')
9
+ return "Model loaded successfully!"
10
+ except Exception as e:
11
+ return str(e)
12
+
13
  # Define a function to apply regex choices to the prompt text
14
  def apply_regex_choices(text):
15
  import re # Import the regular expressions module
 
37
  Create a GIF of a 'Technical Difficulties' television program interruption. The scene should show colored glitchy and typical 'technical difficulties' cable interruptions, (using|with) demonic symbols glitching out along with the colors of the usual 'tech difficulties' broadcasts. The setting should be (an older|a vintage) tv cable broadcast signal interruption. The style should be a realistic cable interruption interlaced with (demonic imagery|dark symbols) glitching out along with the typical color page of interruption in connection. The GIF should last for 1 second.
38
  """
39
 
40
+ # Create the main Gradio interface
41
+ main_iface = gr.Interface(
42
  fn=generate_gif, # The function to call when the user interacts with the interface
43
  inputs=gr.Textbox(lines=10, placeholder="Enter your custom prompt here or use the default template", value=prompt_template), # Input textbox for the prompt
44
  outputs="file", # Output will be a file (the generated GIF)
 
50
  ]
51
  )
52
 
53
+ # Create the model verification interface
54
+ test_iface = gr.Interface(
55
+ fn=verify_model,
56
+ inputs=None,
57
+ outputs="text",
58
+ title="Test Model Loading",
59
+ description="Click the button to test if the model loads correctly."
60
+ )
61
+
62
+ # Combine both interfaces into a single Gradio Block
63
+ block = gr.Blocks()
64
+ with block:
65
+ gr.Markdown("# Structured Prompt GIF Generator")
66
+ gr.Tab("Generate GIFs", main_iface)
67
+ gr.Tab("Verify Model", test_iface)
68
+
69
  # Launch the Gradio interface
70
+ block.launch()
71
+
72