Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	
		maslionok
		
	commited on
		
		
					Commit 
							
							Β·
						
						a4274f6
	
1
								Parent(s):
							
							87c78f3
								
fix
Browse files
    	
        app.py
    CHANGED
    
    | @@ -35,13 +35,13 @@ def process_ocr_qa(text, lang_choice): | |
| 35 |  | 
| 36 | 
             
                        # Language detection
         | 
| 37 | 
             
                        if 'language' in result:
         | 
| 38 | 
            -
                            output_lines.append(f"π  | 
| 39 |  | 
| 40 | 
             
                        # Quality score
         | 
| 41 | 
             
                        if 'score' in result:
         | 
| 42 | 
             
                            score = result['score']
         | 
| 43 | 
             
                            score_emoji = "π’" if score >= 0.8 else "π‘" if score >= 0.5 else "π΄"
         | 
| 44 | 
            -
                            output_lines.append(f"{score_emoji}  | 
| 45 |  | 
| 46 | 
             
                        # Diagnostics section
         | 
| 47 | 
             
                        if 'diagnostics' in result and result['diagnostics']:
         | 
| @@ -49,28 +49,28 @@ def process_ocr_qa(text, lang_choice): | |
| 49 |  | 
| 50 | 
             
                            # Model information
         | 
| 51 | 
             
                            if 'model_id' in diagnostics:
         | 
| 52 | 
            -
                                output_lines.append(f"π€  | 
| 53 |  | 
| 54 | 
             
                            # Known tokens
         | 
| 55 | 
             
                            if 'known_tokens' in diagnostics and diagnostics['known_tokens']:
         | 
| 56 | 
             
                                known_tokens = diagnostics['known_tokens']
         | 
| 57 | 
            -
                                output_lines.append(f"β
  | 
| 58 |  | 
| 59 | 
             
                            # Unknown tokens (potential OCR errors)
         | 
| 60 | 
             
                            if 'unknown_tokens' in diagnostics and diagnostics['unknown_tokens']:
         | 
| 61 | 
             
                                unknown_tokens = diagnostics['unknown_tokens']
         | 
| 62 | 
            -
                                output_lines.append(f"β  | 
| 63 | 
             
                            elif 'unknown_tokens' in diagnostics:
         | 
| 64 | 
            -
                                output_lines.append("β¨  | 
| 65 |  | 
| 66 | 
             
                        # Other fields
         | 
| 67 | 
             
                        for key, value in result.items():
         | 
| 68 | 
             
                            if key not in ['language', 'score', 'diagnostics']:
         | 
| 69 | 
            -
                                output_lines.append(f"π  | 
| 70 |  | 
| 71 | 
             
                        return "\n\n".join(output_lines)
         | 
| 72 | 
             
                    else:
         | 
| 73 | 
            -
                        return f"β¨  | 
| 74 |  | 
| 75 | 
             
                except Exception as e:
         | 
| 76 | 
             
                    print("β Pipeline error:", e)
         | 
|  | |
| 35 |  | 
| 36 | 
             
                        # Language detection
         | 
| 37 | 
             
                        if 'language' in result:
         | 
| 38 | 
            +
                            output_lines.append(f"π Language: {result['language']}")
         | 
| 39 |  | 
| 40 | 
             
                        # Quality score
         | 
| 41 | 
             
                        if 'score' in result:
         | 
| 42 | 
             
                            score = result['score']
         | 
| 43 | 
             
                            score_emoji = "π’" if score >= 0.8 else "π‘" if score >= 0.5 else "π΄"
         | 
| 44 | 
            +
                            output_lines.append(f"{score_emoji} Quality Score: {score:.1f}")
         | 
| 45 |  | 
| 46 | 
             
                        # Diagnostics section
         | 
| 47 | 
             
                        if 'diagnostics' in result and result['diagnostics']:
         | 
|  | |
| 49 |  | 
| 50 | 
             
                            # Model information
         | 
| 51 | 
             
                            if 'model_id' in diagnostics:
         | 
| 52 | 
            +
                                output_lines.append(f"π€ Model: {diagnostics['model_id']}")
         | 
| 53 |  | 
| 54 | 
             
                            # Known tokens
         | 
| 55 | 
             
                            if 'known_tokens' in diagnostics and diagnostics['known_tokens']:
         | 
| 56 | 
             
                                known_tokens = diagnostics['known_tokens']
         | 
| 57 | 
            +
                                output_lines.append(f"β
 Known tokens ({len(known_tokens)}): {', '.join(known_tokens)}")
         | 
| 58 |  | 
| 59 | 
             
                            # Unknown tokens (potential OCR errors)
         | 
| 60 | 
             
                            if 'unknown_tokens' in diagnostics and diagnostics['unknown_tokens']:
         | 
| 61 | 
             
                                unknown_tokens = diagnostics['unknown_tokens']
         | 
| 62 | 
            +
                                output_lines.append(f"β Potential OCR errors ({len(unknown_tokens)}): {', '.join(unknown_tokens)}")
         | 
| 63 | 
             
                            elif 'unknown_tokens' in diagnostics:
         | 
| 64 | 
            +
                                output_lines.append("β¨ No potential OCR errors detected!")
         | 
| 65 |  | 
| 66 | 
             
                        # Other fields
         | 
| 67 | 
             
                        for key, value in result.items():
         | 
| 68 | 
             
                            if key not in ['language', 'score', 'diagnostics']:
         | 
| 69 | 
            +
                                output_lines.append(f"π {key.replace('_', ' ').title()}: {value}")
         | 
| 70 |  | 
| 71 | 
             
                        return "\n\n".join(output_lines)
         | 
| 72 | 
             
                    else:
         | 
| 73 | 
            +
                        return f"β¨ Processed Result:\n{result}"
         | 
| 74 |  | 
| 75 | 
             
                except Exception as e:
         | 
| 76 | 
             
                    print("β Pipeline error:", e)
         | 
