Update app.py
Browse files
app.py
CHANGED
@@ -68,33 +68,28 @@ def load_models():
|
|
68 |
|
69 |
vision_model, vision_processor, code_model, code_tokenizer = load_models()
|
70 |
|
71 |
-
VISION_SYSTEM_PROMPT = """
|
72 |
-
1.
|
73 |
-
2.
|
74 |
-
|
75 |
-
|
76 |
-
Output Format:
|
77 |
-
```[language]
|
78 |
-
[extracted code here]
|
79 |
If multiple code sections are visible, separate them with ---
|
80 |
Note: In video, irrelevant frames may occur (e.g., other windows tabs, eterniq website, etc.) in video. Please focus on code-specific frames as we have to extract that content only.
|
81 |
"""
|
82 |
|
83 |
-
CODE_SYSTEM_PROMPT = """
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
3. Provide a corrected version of the code
|
91 |
-
4. Explain the specific fixes made
|
92 |
-
Output Format:
|
93 |
Fixed Code:
|
94 |
-
[corrected code
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
98 |
"""
|
99 |
def process_video_for_code(video_path, transcribed_text, max_frames=16, frame_interval=30):
|
100 |
cap = cv2.VideoCapture(video_path)
|
|
|
68 |
|
69 |
vision_model, vision_processor, code_model, code_tokenizer = load_models()
|
70 |
|
71 |
+
VISION_SYSTEM_PROMPT = """Extract code from images/videos:
|
72 |
+
1. Output exact code snippets only
|
73 |
+
2. Keep original formatting/indentation
|
74 |
+
focus on code-relevant frames only
|
75 |
+
[code]
|
|
|
|
|
|
|
76 |
If multiple code sections are visible, separate them with ---
|
77 |
Note: In video, irrelevant frames may occur (e.g., other windows tabs, eterniq website, etc.) in video. Please focus on code-specific frames as we have to extract that content only.
|
78 |
"""
|
79 |
|
80 |
+
CODE_SYSTEM_PROMPT = """Debug code as an expert:
|
81 |
+
- Analyze OCR-extracted code + user's issue
|
82 |
+
- Find bugs/issues
|
83 |
+
- Provide fixes
|
84 |
+
- Explain corrections
|
85 |
+
|
86 |
+
Output:
|
|
|
|
|
|
|
87 |
Fixed Code:
|
88 |
+
[corrected code]
|
89 |
+
|
90 |
+
Original Issue:
|
91 |
+
[brief analysis]
|
92 |
+
Note: Please provide the output in a well-structured Markdown format. Remove all unnecessary information and exclude any additional code formatting such as triple backticks or language identifiers.
|
93 |
"""
|
94 |
def process_video_for_code(video_path, transcribed_text, max_frames=16, frame_interval=30):
|
95 |
cap = cv2.VideoCapture(video_path)
|