SyedTahir commited on
Commit
897101a
Β·
verified Β·
1 Parent(s): 64ae4b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +361 -202
app.py CHANGED
@@ -1,254 +1,413 @@
1
  import gradio as gr
2
  import torch
3
- from transformers import AutoModelForCausalLM, AutoTokenizer
4
- from peft import PeftModel, PeftConfig
5
- import os
6
 
7
- # App metadata
8
- APP_TITLE = "πŸ” STHASI Code Review Assistant"
9
- APP_DESCRIPTION = """
10
- An AI-powered code review assistant that analyzes code quality, detects vulnerabilities, and suggests improvements.
11
- Built with ❀️ by **[Syed Tahir Hussan](https://www.linkedin.com/in/syedtahirhussan/)**
12
-
13
- **Features:**
14
- - πŸ›‘οΈ Security vulnerability detection across 13+ languages
15
- - πŸ“Š Code quality analysis
16
- - πŸ’‘ Improvement suggestions
17
- - πŸ› Bug detection
18
-
19
- **Supported Languages:** Python, JavaScript, Java, C, C++, C#, Go, PHP, Ruby, Swift, Kotlin, TypeScript, Fortran
20
- """
21
-
22
- FOOTER = """
23
- ---
24
- **STHASI Code Review Assistant** | Built with ❀️ by [Syed Tahir Hussan](https://www.linkedin.com/in/syedtahirhussan/)
25
-
26
- πŸ“§ [GitHub](https://github.com/SyedTahirHussan) | πŸ’Ό [LinkedIn](https://www.linkedin.com/in/syedtahirhussan/)
27
-
28
- *Powered by CodeAstra-7B & Hugging Face Spaces*
29
- """
30
-
31
- # Global variables for model
32
  model = None
33
  tokenizer = None
34
- model_loaded = False
35
 
36
  def load_model():
37
- """Load the CodeAstra-7B model"""
38
- global model, tokenizer, model_loaded
39
 
40
- if model_loaded:
41
- return "Model already loaded!"
42
-
43
- try:
44
- peft_model_id = "rootxhacker/CodeAstra-7B"
45
- config = PeftConfig.from_pretrained(peft_model_id)
46
 
47
- # Load model in 4-bit for efficiency
48
  model = AutoModelForCausalLM.from_pretrained(
49
- config.base_model_name_or_path,
50
- return_dict=True,
51
- load_in_4bit=True,
52
- device_map='auto',
53
  trust_remote_code=True
54
  )
55
- tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
56
-
57
- # Load PEFT adapter
58
- model = PeftModel.from_pretrained(model, peft_model_id)
59
 
60
- model_loaded = True
61
- return "βœ… Model loaded successfully!"
62
- except Exception as e:
63
- return f"❌ Error loading model: {str(e)}"
64
-
65
- def analyze_code(code_input, analysis_type, language):
66
- """
67
- Analyze code for vulnerabilities and quality issues
68
-
69
- Args:
70
- code_input: The code to analyze
71
- analysis_type: Type of analysis (vulnerability, quality, both)
72
- language: Programming language
73
- """
74
- global model, tokenizer, model_loaded
75
-
76
- if not code_input.strip():
77
- return "⚠️ Please enter some code to analyze."
78
-
79
- if not model_loaded:
80
- return "⚠️ Model not loaded. Please wait for initialization or refresh the page."
81
 
 
 
 
 
82
  try:
83
- # Construct the prompt based on analysis type
84
- if analysis_type == "Security Vulnerabilities":
85
- prompt = f"""Analyze the following {language} code for security vulnerabilities.
86
- Identify any potential security issues, explain their severity, and suggest fixes.
87
-
88
- Code:
89
- ```{language.lower()}
90
- {code_input}
 
 
91
  ```
92
 
93
- Analysis:"""
94
- elif analysis_type == "Code Quality":
95
- prompt = f"""Review the following {language} code for quality issues.
96
- Check for: code smell, performance issues, best practices, readability, and maintainability.
 
 
 
97
 
98
- Code:
99
- ```{language.lower()}
100
- {code_input}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  ```
102
 
103
- Review:"""
104
- else: # Both
105
- prompt = f"""Perform a comprehensive code review of the following {language} code.
106
- Analyze both security vulnerabilities AND code quality issues.
 
 
 
 
 
 
 
 
107
 
108
- Code:
109
- ```{language.lower()}
110
- {code_input}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  ```
112
 
113
- Comprehensive Analysis:"""
114
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  # Generate response
116
- inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
117
-
118
- with torch.no_grad():
119
- outputs = model.generate(
120
- **inputs,
121
- max_new_tokens=1024,
122
- do_sample=True,
123
- temperature=0.3,
124
- top_p=0.95,
125
- repetition_penalty=1.15,
126
- pad_token_id=tokenizer.eos_token_id
127
- )
128
-
129
- result = tokenizer.decode(outputs[0], skip_special_tokens=True)
130
-
131
- # Extract only the analysis part (remove the prompt)
132
- if "Analysis:" in result:
133
- result = result.split("Analysis:")[-1].strip()
134
- elif "Review:" in result:
135
- result = result.split("Review:")[-1].strip()
136
- elif "Comprehensive Analysis:" in result:
137
- result = result.split("Comprehensive Analysis:")[-1].strip()
138
-
139
- return f"## πŸ“‹ Analysis Results\n\n{result}"
140
 
141
  except Exception as e:
142
- return f"❌ Error during analysis: {str(e)}\n\nPlease try again or contact support."
143
 
144
- # Example codes for different languages
145
- EXAMPLES = {
146
- "Python - SQL Injection": '''def user_login(username, password):
147
- query = f"SELECT * FROM users WHERE username='{username}' AND password='{password}'"
148
- cursor.execute(query)
149
- return cursor.fetchone()''',
150
-
151
- "JavaScript - XSS": '''function displayUserInput() {
152
- var userInput = document.getElementById("input").value;
153
- document.getElementById("output").innerHTML = userInput;
154
- }''',
155
-
156
- "Python - Hardcoded Secrets": '''import requests
157
-
158
- API_KEY = "sk-1234567890abcdef"
159
- DB_PASSWORD = "admin123"
160
-
161
- def connect_to_api():
162
- headers = {"Authorization": f"Bearer {API_KEY}"}
163
- return requests.get("https://api.example.com", headers=headers)''',
164
 
165
- "Java - Resource Leak": '''public void readFile(String filename) throws IOException {
166
- FileInputStream fis = new FileInputStream(filename);
167
- BufferedReader br = new BufferedReader(new InputStreamReader(fis));
168
- String line = br.readLine();
169
- System.out.println(line);
170
- }''',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
- "C - Buffer Overflow": '''#include <string.h>
173
- #include <stdio.h>
174
-
175
- void copy_input(char *input) {
176
- char buffer[10];
177
- strcpy(buffer, input);
178
- printf("Input: %s\\n", buffer);
179
- }'''
180
- }
181
-
182
- # Create Gradio interface
183
- def create_interface():
184
- with gr.Blocks(theme=gr.themes.Soft(), css=".footer {text-align: center; margin-top: 20px;}") as app:
185
- gr.Markdown(f"# {APP_TITLE}")
186
- gr.Markdown(APP_DESCRIPTION)
 
 
 
 
 
 
 
 
 
 
 
187
 
188
  with gr.Row():
189
- with gr.Column(scale=2):
 
 
190
  code_input = gr.Code(
191
- label="πŸ“ Paste Your Code Here",
192
  language="python",
193
  lines=15,
194
- placeholder="Enter your code here for analysis..."
 
 
 
 
 
 
 
195
  )
196
 
197
- with gr.Row():
198
- language_select = gr.Dropdown(
199
- choices=[
200
- "Python", "JavaScript", "Java", "C", "C++", "C#",
201
- "Go", "PHP", "Ruby", "Swift", "Kotlin", "TypeScript", "Fortran"
202
- ],
203
- value="Python",
204
- label="πŸ”€ Programming Language"
 
 
 
 
 
 
 
 
 
 
 
 
205
  )
206
 
207
- analysis_type = gr.Radio(
208
- choices=["Security Vulnerabilities", "Code Quality", "Both"],
209
- value="Both",
210
- label="πŸ” Analysis Type"
 
 
 
211
  )
212
 
213
  analyze_btn = gr.Button("πŸš€ Analyze Code", variant="primary", size="lg")
 
 
 
214
 
215
- gr.Markdown("### πŸ“š Example Vulnerable Code")
216
- example_dropdown = gr.Dropdown(
217
- choices=list(EXAMPLES.keys()),
218
- label="Load Example",
219
- interactive=True
220
  )
221
-
222
- with gr.Column(scale=2):
223
- output = gr.Markdown(label="Analysis Results")
224
 
225
- # Event handlers
226
- analyze_btn.click(
227
- fn=analyze_code,
228
- inputs=[code_input, analysis_type, language_select],
229
- outputs=output
230
- )
231
 
232
- def load_example(example_name):
233
- if example_name:
234
- return EXAMPLES[example_name]
235
- return ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
- example_dropdown.change(
238
- fn=load_example,
239
- inputs=example_dropdown,
240
- outputs=code_input
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  )
242
 
243
- gr.Markdown(FOOTER, elem_classes="footer")
 
 
 
 
 
 
 
 
 
 
 
 
 
244
 
245
- # Auto-load model on startup
246
- app.load(load_model, inputs=None, outputs=None)
 
 
 
 
 
247
 
248
- return app
249
 
250
- # Launch the app
251
  if __name__ == "__main__":
252
- demo = create_interface()
253
- demo.queue()
254
- demo.launch(share=True)
 
 
 
 
 
 
1
  import gradio as gr
2
  import torch
3
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
4
+ import re
 
5
 
6
+ # Global variables to store model and tokenizer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  model = None
8
  tokenizer = None
9
+ pipe = None
10
 
11
  def load_model():
12
+ """Load the model and tokenizer"""
13
+ global model, tokenizer, pipe
14
 
15
+ if pipe is None:
16
+ print("Loading model...")
17
+ model_name = "Qwen/Qwen2.5-Coder-7B-Instruct"
 
 
 
18
 
19
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
20
  model = AutoModelForCausalLM.from_pretrained(
21
+ model_name,
22
+ torch_dtype=torch.bfloat16,
23
+ device_map="auto",
 
24
  trust_remote_code=True
25
  )
 
 
 
 
26
 
27
+ pipe = pipeline(
28
+ "text-generation",
29
+ model=model,
30
+ tokenizer=tokenizer,
31
+ torch_dtype=torch.bfloat16,
32
+ device_map="auto"
33
+ )
34
+ print("Model loaded successfully!")
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ return pipe
37
+
38
+ def analyze_code(code, language, analysis_type, temperature, max_tokens):
39
+ """Analyze code for quality, security, and improvements"""
40
  try:
41
+ # Load model if not already loaded
42
+ generator = load_model()
43
+
44
+ # Construct detailed prompt based on analysis type
45
+ if analysis_type == "πŸ” Full Analysis (Quality + Security + Improvements)":
46
+ prompt = f"""You are an expert code reviewer. Analyze the following {language} code comprehensively:
47
+
48
+ **Code to Review:**
49
+ ```{language}
50
+ {code}
51
  ```
52
 
53
+ **Please provide a detailed analysis including:**
54
+
55
+ 1. **Code Quality Assessment:**
56
+ - Code structure and organization
57
+ - Naming conventions and readability
58
+ - Code complexity and maintainability
59
+ - Best practices adherence
60
 
61
+ 2. **Security Vulnerabilities:**
62
+ - Identify security flaws (SQL injection, XSS, authentication issues, etc.)
63
+ - Rate severity (Critical/High/Medium/Low)
64
+ - Explain potential exploits
65
+
66
+ 3. **Improvement Suggestions:**
67
+ - Performance optimizations
68
+ - Refactoring recommendations
69
+ - Better coding patterns
70
+ - Updated or improved code snippets
71
+
72
+ 4. **Overall Rating:** Rate the code quality (1-10) with justification.
73
+
74
+ Provide specific, actionable feedback with code examples where applicable."""
75
+
76
+ elif analysis_type == "πŸ›‘οΈ Security Vulnerabilities Only":
77
+ prompt = f"""You are a cybersecurity expert specializing in code security. Analyze the following {language} code for security vulnerabilities:
78
+
79
+ **Code to Review:**
80
+ ```{language}
81
+ {code}
82
+ ```
83
+
84
+ **Please identify:**
85
+
86
+ 1. **Security Vulnerabilities:**
87
+ - List all security issues (injection attacks, authentication flaws, data exposure, etc.)
88
+ - Severity rating for each (Critical/High/Medium/Low)
89
+ - CVE references if applicable
90
+ - Potential attack vectors
91
+
92
+ 2. **Secure Code Examples:**
93
+ - Provide fixed/secure versions of vulnerable code
94
+ - Explain why the changes improve security
95
+
96
+ 3. **Security Best Practices:**
97
+ - Recommendations specific to this code
98
+ - Industry-standard security patterns
99
+
100
+ Focus exclusively on security concerns."""
101
+
102
+ elif analysis_type == "✨ Code Quality & Improvements":
103
+ prompt = f"""You are a senior software engineer reviewing code quality. Analyze the following {language} code:
104
+
105
+ **Code to Review:**
106
+ ```{language}
107
+ {code}
108
  ```
109
 
110
+ **Please evaluate:**
111
+
112
+ 1. **Code Quality:**
113
+ - Readability and maintainability
114
+ - Code organization and structure
115
+ - Naming conventions
116
+ - Documentation quality
117
+
118
+ 2. **Performance:**
119
+ - Efficiency concerns
120
+ - Resource utilization
121
+ - Algorithmic complexity
122
 
123
+ 3. **Improvements:**
124
+ - Refactoring suggestions
125
+ - Design pattern recommendations
126
+ - Better implementation approaches
127
+ - Optimized code examples
128
+
129
+ 4. **Best Practices:**
130
+ - Language-specific conventions
131
+ - Industry standards compliance
132
+
133
+ Provide constructive feedback with examples."""
134
+
135
+ else: # Bug Detection
136
+ prompt = f"""You are an expert debugger. Analyze the following {language} code to find bugs and issues:
137
+
138
+ **Code to Review:**
139
+ ```{language}
140
+ {code}
141
  ```
142
 
143
+ **Please identify:**
144
+
145
+ 1. **Bugs and Errors:**
146
+ - Syntax errors
147
+ - Logic errors
148
+ - Runtime errors
149
+ - Edge case failures
150
+
151
+ 2. **Potential Issues:**
152
+ - Null pointer exceptions
153
+ - Memory leaks
154
+ - Race conditions
155
+ - Unhandled exceptions
156
+
157
+ 3. **Fixes:**
158
+ - Corrected code snippets
159
+ - Explanation of the fix
160
+
161
+ Focus on identifying and fixing bugs."""
162
+
163
  # Generate response
164
+ messages = [{"role": "user", "content": prompt}]
165
+
166
+ response = generator(
167
+ messages,
168
+ max_new_tokens=max_tokens,
169
+ temperature=temperature,
170
+ top_p=0.95,
171
+ do_sample=True,
172
+ repetition_penalty=1.1
173
+ )
174
+
175
+ # Extract the generated text
176
+ result = response[0]["generated_text"]
177
+
178
+ # Get only the assistant's response
179
+ if isinstance(result, list):
180
+ assistant_response = result[-1]["content"]
181
+ else:
182
+ assistant_response = result
183
+
184
+ return assistant_response
 
 
 
185
 
186
  except Exception as e:
187
+ return f"❌ **Error during analysis:** {str(e)}\n\nPlease try again or contact support."
188
 
189
+ def create_demo():
190
+ """Create the Gradio interface"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
+ # Custom CSS for better styling
193
+ custom_css = """
194
+ .gradio-container {
195
+ font-family: 'IBM Plex Sans', sans-serif;
196
+ }
197
+ .header {
198
+ text-align: center;
199
+ padding: 20px;
200
+ background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
201
+ color: white;
202
+ border-radius: 10px;
203
+ margin-bottom: 20px;
204
+ }
205
+ .footer {
206
+ text-align: center;
207
+ padding: 15px;
208
+ margin-top: 20px;
209
+ border-top: 1px solid #e0e0e0;
210
+ }
211
+ .example-box {
212
+ background-color: #f5f5f5;
213
+ padding: 15px;
214
+ border-radius: 5px;
215
+ margin: 10px 0;
216
+ }
217
+ """
218
 
219
+ with gr.Blocks(css=custom_css, title="STHASI Code Review Assistant", theme=gr.themes.Soft()) as demo:
220
+
221
+ # Header
222
+ gr.HTML("""
223
+ <div class="header">
224
+ <h1>πŸ”’ STHASI Code Review Assistant</h1>
225
+ <p style="font-size: 18px; margin: 10px 0;">
226
+ AI-Powered Code Quality & Security Analysis
227
+ </p>
228
+ <p style="font-size: 14px; opacity: 0.9;">
229
+ Built with ❀️ by <a href="https://www.linkedin.com/in/syedtahirhussan/" style="color: white; text-decoration: underline;" target="_blank">Syed Tahir Hussan</a>
230
+ </p>
231
+ </div>
232
+ """)
233
+
234
+ gr.Markdown("""
235
+ ## πŸ‘‹ Welcome to STHASI Code Review Assistant!
236
+
237
+ This AI-powered tool analyzes your code for:
238
+ - βœ… **Code Quality**: Structure, readability, and best practices
239
+ - πŸ›‘οΈ **Security Vulnerabilities**: SQL injection, XSS, authentication flaws, and more
240
+ - πŸ’‘ **Improvements**: Performance optimizations and refactoring suggestions
241
+ - πŸ› **Bug Detection**: Logic errors, edge cases, and potential issues
242
+
243
+ **Powered by Qwen2.5-Coder-7B-Instruct** - State-of-the-art code understanding model
244
+ """)
245
 
246
  with gr.Row():
247
+ with gr.Column(scale=1):
248
+ gr.Markdown("### πŸ“ Input Code")
249
+
250
  code_input = gr.Code(
251
+ label="Paste your code here",
252
  language="python",
253
  lines=15,
254
+ placeholder="# Paste your code here...\ndef example_function():\n pass"
255
+ )
256
+
257
+ language = gr.Dropdown(
258
+ choices=["python", "javascript", "java", "cpp", "c", "csharp", "go", "rust", "php", "ruby", "typescript", "sql", "bash", "kotlin", "swift"],
259
+ value="python",
260
+ label="Programming Language",
261
+ info="Select the programming language of your code"
262
  )
263
 
264
+ analysis_type = gr.Radio(
265
+ choices=[
266
+ "πŸ” Full Analysis (Quality + Security + Improvements)",
267
+ "πŸ›‘οΈ Security Vulnerabilities Only",
268
+ "✨ Code Quality & Improvements",
269
+ "πŸ› Bug Detection"
270
+ ],
271
+ value="πŸ” Full Analysis (Quality + Security + Improvements)",
272
+ label="Analysis Type",
273
+ info="Choose what aspect to focus on"
274
+ )
275
+
276
+ with gr.Accordion("βš™οΈ Advanced Settings", open=False):
277
+ temperature = gr.Slider(
278
+ minimum=0.1,
279
+ maximum=1.0,
280
+ value=0.7,
281
+ step=0.1,
282
+ label="Temperature",
283
+ info="Higher = more creative, Lower = more focused"
284
  )
285
 
286
+ max_tokens = gr.Slider(
287
+ minimum=512,
288
+ maximum=4096,
289
+ value=2048,
290
+ step=256,
291
+ label="Max Tokens",
292
+ info="Maximum length of the analysis"
293
  )
294
 
295
  analyze_btn = gr.Button("πŸš€ Analyze Code", variant="primary", size="lg")
296
+
297
+ with gr.Column(scale=1):
298
+ gr.Markdown("### πŸ“Š Analysis Results")
299
 
300
+ output = gr.Markdown(
301
+ label="Review Results",
302
+ value="*Analysis results will appear here...*"
 
 
303
  )
 
 
 
304
 
305
+ # Examples section
306
+ gr.Markdown("### πŸ’‘ Example Codes to Try")
 
 
 
 
307
 
308
+ with gr.Row():
309
+ with gr.Column():
310
+ gr.Markdown("""
311
+ **Example 1: SQL Injection Vulnerability**
312
+ ```python
313
+ def get_user(username):
314
+ query = f"SELECT * FROM users WHERE name = '{username}'"
315
+ return db.execute(query)
316
+ ```
317
+ """)
318
+
319
+ with gr.Column():
320
+ gr.Markdown("""
321
+ **Example 2: Insecure Password Storage**
322
+ ```python
323
+ def store_password(password):
324
+ # Bad practice: storing plain text
325
+ with open('passwords.txt', 'a') as f:
326
+ f.write(password + '\\n')
327
+ ```
328
+ """)
329
 
330
+ # Examples for quick testing
331
+ gr.Examples(
332
+ examples=[
333
+ [
334
+ """def login(username, password):
335
+ query = f"SELECT * FROM users WHERE username='{username}' AND password='{password}'"
336
+ result = db.execute(query)
337
+ if result:
338
+ return True
339
+ return False""",
340
+ "python",
341
+ "πŸ›‘οΈ Security Vulnerabilities Only",
342
+ 0.7,
343
+ 2048
344
+ ],
345
+ [
346
+ """function validateEmail(email) {
347
+ return email.includes('@');
348
+ }
349
+
350
+ function processUserInput(input) {
351
+ document.getElementById('output').innerHTML = input;
352
+ }""",
353
+ "javascript",
354
+ "πŸ” Full Analysis (Quality + Security + Improvements)",
355
+ 0.7,
356
+ 2048
357
+ ],
358
+ [
359
+ """public class Calculator {
360
+ public int divide(int a, int b) {
361
+ return a / b;
362
+ }
363
+
364
+ public String getUserData(String userId) {
365
+ return "SELECT * FROM users WHERE id=" + userId;
366
+ }
367
+ }""",
368
+ "java",
369
+ "πŸ› Bug Detection",
370
+ 0.7,
371
+ 2048
372
+ ]
373
+ ],
374
+ inputs=[code_input, language, analysis_type, temperature, max_tokens],
375
+ outputs=output,
376
+ fn=analyze_code,
377
+ cache_examples=False
378
  )
379
 
380
+ # Footer
381
+ gr.HTML("""
382
+ <div class="footer">
383
+ <p>
384
+ <strong>Built with ❀️ by Syed Tahir Hussan</strong><br>
385
+ πŸ”— <a href="https://www.linkedin.com/in/syedtahirhussan/" target="_blank">LinkedIn</a> |
386
+ πŸ’» <a href="https://github.com/SyedTahirHussan" target="_blank">GitHub</a><br>
387
+ <em>Powered by Qwen2.5-Coder-7B-Instruct & Gradio 5.49.1</em>
388
+ </p>
389
+ <p style="font-size: 12px; color: #666; margin-top: 10px;">
390
+ ⚠️ Note: This is an AI-powered tool. Always verify critical security findings with manual review and security experts.
391
+ </p>
392
+ </div>
393
+ """)
394
 
395
+ # Event handler
396
+ analyze_btn.click(
397
+ fn=analyze_code,
398
+ inputs=[code_input, language, analysis_type, temperature, max_tokens],
399
+ outputs=output,
400
+ api_name="analyze"
401
+ )
402
 
403
+ return demo
404
 
 
405
  if __name__ == "__main__":
406
+ demo = create_demo()
407
+ demo.queue(max_size=10)
408
+ demo.launch(
409
+ server_name="0.0.0.0",
410
+ server_port=7860,
411
+ share=False,
412
+ show_error=True
413
+ )