fffiloni commited on
Commit
df4cffb
1 Parent(s): b92bee7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -19
app.py CHANGED
@@ -60,16 +60,17 @@ title = """
60
  font-size: 1.75rem;
61
  "
62
  >
63
- <h1 style="font-weight: 900; margin-bottom: 7px;">
64
  CLIP Interrogator 2.1
65
  </h1>
66
  </div>
67
- <p style="margin-bottom: 10px; font-size: 94%">
68
  Want to figure out what a good prompt might be to create new images like an existing one? The CLIP Interrogator is here to get you answers!
69
  <br />This version is specialized for producing nice prompts for use with Stable Diffusion 2.0 using the ViT-H-14 OpenCLIP model!
70
  </p>
71
  </div>
72
  """
 
73
  article = """
74
  <div style="text-align: center; max-width: 650px; margin: 0 auto;">
75
 
@@ -85,21 +86,50 @@ article = """
85
  </div>
86
  """
87
 
88
- inputs = [
89
- gr.inputs.Image(type='pil'),
90
- gr.Radio(['best', 'classic', 'fast'], label='', value='best'),
91
- gr.Number(value=4, label='best mode max flavors'),
92
- ]
93
- outputs = [
94
- gr.outputs.Textbox(label="Output"),
95
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- io = gr.Interface(
98
- inference,
99
- inputs,
100
- outputs,
101
- allow_flagging=False,
102
- title=title,
103
- article=article
104
- )
105
- io.launch()
60
  font-size: 1.75rem;
61
  "
62
  >
63
+ <h1 style="font-weight: 600; margin-bottom: 7px;">
64
  CLIP Interrogator 2.1
65
  </h1>
66
  </div>
67
+ <p style="margin-bottom: 10px;font-size: 16px;font-weight: 100;line-height: 1.5em;">
68
  Want to figure out what a good prompt might be to create new images like an existing one? The CLIP Interrogator is here to get you answers!
69
  <br />This version is specialized for producing nice prompts for use with Stable Diffusion 2.0 using the ViT-H-14 OpenCLIP model!
70
  </p>
71
  </div>
72
  """
73
+
74
  article = """
75
  <div style="text-align: center; max-width: 650px; margin: 0 auto;">
76
 
86
  </div>
87
  """
88
 
89
+ css = '''
90
+ #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
91
+ a {text-decoration-line: underline; font-weight: 600;}
92
+ .animate-spin {
93
+ animation: spin 1s linear infinite;
94
+ }
95
+ @keyframes spin {
96
+ from {
97
+ transform: rotate(0deg);
98
+ }
99
+ to {
100
+ transform: rotate(360deg);
101
+ }
102
+ }
103
+ #share-btn-container {
104
+ display: flex; padding-left: 0.5rem !important; padding-right: 0.5rem !important; background-color: #000000; justify-content: center; align-items: center; border-radius: 9999px !important; width: 13rem;
105
+ }
106
+ #share-btn {
107
+ all: initial; color: #ffffff;font-weight: 600; cursor:pointer; font-family: 'IBM Plex Sans', sans-serif; margin-left: 0.5rem !important; padding-top: 0.25rem !important; padding-bottom: 0.25rem !important;
108
+ }
109
+ #share-btn * {
110
+ all: unset;
111
+ }
112
+ #share-btn-container div:nth-child(-n+2){
113
+ width: auto !important;
114
+ min-height: 0px !important;
115
+ }
116
+ #share-btn-container .wrap {
117
+ display: none !important;
118
+ }
119
+ '''
120
+
121
+ with gr.Blocks(css=css) as block:
122
+ with gr.Column(elem_id="col-container"):
123
+ gr.HTML(title)
124
+
125
+ input_image = gr.Image(type='pil', elem_id="input-img")
126
+ mode_input = gr.Radio(['best', 'classic', 'fast'], label='', value='best')
127
+ flavor_input = gr.Number(value=4, label='best mode max flavors')
128
+ submit_btn = gr.Button("Submit")
129
+ output_text = gr.Textbox(label="Output", elem_id="output-txt")
130
+
131
+ gr.HTML(article)
132
+
133
+ submit_btn.click(fn=inference, inputs=[input_image,mode_input,flavor_input], outputs=[output_text])
134
 
135
+ block.queue(max_size=32).launch(show_api=False)