0% found this document useful (0 votes)
6 views5 pages

Technical Documentation with Code Snippets

Uploaded by

shashank 405
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Technical Documentation with Code Snippets

Uploaded by

shashank 405
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Extensive Technical Documentation

with Code Snippets


Date: 2025-09-22
Version: 2.1

1. Introduction
This extended version of the documentation includes key code snippets from the project
files. It provides not only descriptions but also actual implementation excerpts for models,
HTML frontend, Flask backend, and utility scripts.

2. AI Models and Loading Mechanism

2.1 InternVL (Vision-Language Model)


InternVL is loaded using Hugging Face Transformers. Below is the code excerpt from
`[Link]`:

internvl_model_path = [Link]("Models", "InternVL2_5-1B-


MPO")
model_int = AutoModel.from_pretrained(
internvl_model_path,
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=True,
trust_remote_code=True
).eval()

# Disable dropout for inference


for module in model_int.modules():
if isinstance(module, [Link]):
module.p = 0

tokenizer_int =
AutoTokenizer.from_pretrained(internvl_model_path,
trust_remote_code=True)
2.2 EasyOCR
EasyOCR initialization snippet:

reader = [Link](['en', 'hi'], gpu=False) # Supports English


and Hindi

2.3 CLIP
CLIP loading snippet from `[Link]`:

clip_model_path = [Link]("Models", "clip-vit-base-patch32")


processor_clip = AutoProcessor.from_pretrained(clip_model_path)
model_clip =
AutoModelForZeroShotImageClassification.from_pretrained(clip_mo
del_path).to(device)

3. Pipeline Example Functions

3.1 Tagline Check

def tagline(image_path):
results = {
"Empty/Illegible/Black Tagline": 0,
"Multiple Taglines": 0,
"Incomplete Tagline": 0,
"Hyperlink": 0,
"Price Tag": 0,
"Excessive Emojis": 0
}

image = get_roi(image_path, *TAG)


easytag = easyocr_ocr(image).lower().strip()

if is_blank(easytag):
results["Empty/Illegible/Black Tagline"] = 1
return results

# Additional logic for completeness, hyperlink, emojis etc.


return results

3.2 Body Risk Detection

def is_risky(body):
risky_keywords = ["casino", "poker", "bet365", "dream11", "win
cash"]
for keyword in risky_keywords:
if find_similar_substring(body, keyword):
return True
return False

4. HTML Frontend Snippets

4.1 Dropzone Initialization (`[Link]`)

[Link] = {
paramName: "file",
maxFilesize: 16,
acceptedFiles: "image/*",
init: function() {
[Link]("addedfile", function(file) {
fetch('/clear_uploads', { method: 'POST' });
});
}
};

4.2 Table Row Creation

function createTableRow(result, index) {


return `
<tr>
<td class="serial">${index + 1}</td>
<td class="image-col">
<img src="data:image/jpeg;base64,${[Link]}"
class="thumbnail">
</td>
<td class="result-col">
<span class="result-${[Link]()}">$
{[Link]}</span>
</td>
<td class="labels-col">
${[Link](label => `<span class="label">$
{label}</span>`).join('')}
</td>
</tr>`;
}

5. Flask Backend Snippets

5.1 Upload and Classify Multiple

@[Link]('/classify_multiple', methods=['POST'])
def classify_multiple():
temp_dir = [Link]([Link]['UPLOAD_FOLDER_MULTIPLE'],
'temp')
files = [f for f in [Link](temp_dir) if allowed_file(f)]
for filename in files:
filepath = [Link](temp_dir, filename)
classification_result, result_table, failure_labels =
classify(filepath)
return jsonify({
'filename': filename,
'status': classification_result,
'labels': failure_labels
})

6. ADB Automation Snippet

def capture_screenshot(folder):
screenshot_name = f"screenshot_{[Link]().strftime('%H-
%M-%S')}.png"
screenshot_path = [Link](folder, screenshot_name)
[Link](['adb', 'exec-out', 'screencap', '-p'],
stdout=open(screenshot_path, 'wb'), check=True)
mask_dynamic_regions(screenshot_path)
return screenshot_path

7. Duplicate Remover Snippet

def find_similar(dir, hash_tresh=5):


for filename in [Link](dir):
if not [Link]().endswith('.png'):
continue
with [Link]([Link](dir, filename)) as img:
wallp = crop_botton_two_thirds(img)
wall_hash = [Link](wallp)
# Compare with previous hashes and delete if similar

8. Conclusion
This expanded document combines descriptions with code snippets from key modules. It
provides both conceptual and implementation-level insights into how models, pipeline,
frontend, backend, and utilities are implemented.

You might also like