Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S SynthText
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 25
    • Issues 25
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Ankush Gupta
  • SynthText
  • Merge requests
  • !191

Data not found and have problems downloading.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open northwill requested to merge github/fork/adavoudi/python3 into python3 4 years ago
  • Overview 1
  • Commits 13
  • Pipelines 1
  • Changes 14

getting data.. downloading data (24 M) from: https://www.dropbox.com/s/nagp2q3twqtyi02/data.zip?dl=1 Data not found and have problems downloading.

Compare
  • version 1
    27d3b941
    2 years ago

  • python3 (base)

and
  • latest version
    27d3b941
    13 commits, 2 years ago

  • version 1
    27d3b941
    13 commits, 2 years ago

14 files
+ 1248
- 124

    Preferences

    File browser
    Compare changes
prep_s‎cripts‎
floodF‎ill.py‎ +8 -8
invert_fo‎nt_size.py‎ +10 -10
update_‎freq.py‎ +21 -0
.giti‎gnore‎ +1 -0
READ‎ME.md‎ +29 -0
colorize3_‎poisson.py‎ +21 -0
environ‎ment.yml‎ +69 -0
fribi‎di.py‎ +1000 -0
gen‎.py‎ +3 -3
poisson_rec‎onstruct.py‎ +3 -3
sample‎_fa.png‎ +0 -0
synth‎gen.py‎ +56 -50
text_u‎tils.py‎ +25 -48
visualize_‎results.py‎ +2 -2
prep_scripts/floodFill.py
+ 8
- 8
  • View file @ 27d3b941

  • Edit in single-file editor

  • Open in Web IDE


@@ -17,7 +17,7 @@ import traceback, sys
def get_seed(sx,sy,ucm):
n = sx.size
for i in xrange(n):
for i in range(n):
if ucm[sx[i]+1,sy[i]+1] == 0:
return (sy[i],sx[i])
@@ -41,7 +41,7 @@ def get_mask(ucm,viz=False):
sx,sy = np.where(mask==0)
seed = get_seed(sx,sy,ucm)
i += 1
print " > terminated in %d steps"%i
print(" > terminated in %d steps"%i)
if viz:
plt.imshow(mask)
@@ -81,7 +81,7 @@ def process_db_parallel(base_dir, th=0.11):
return "".join(map(chr, self.ucm_h5[self.ucm_h5['names'][0,self.i]][:]))
def __stop__(self):
print "DONE"
print("DONE")
self.ucm_h5.close()
raise StopIteration
@@ -101,14 +101,14 @@ def process_db_parallel(base_dir, th=0.11):
def next(self):
imname = self.get_valid_name()
print "%d of %d"%(self.i+1,self.N)
print ("%d of %d"%(self.i+1,self.N))
ucm = self.ucm_h5[self.ucm_h5['ucms'][0,self.i]][:]
ucm = ucm.copy()
self.i += 1
return ((ucm>self.th).astype('uint8'),imname)
ucm_iter = ucm_iterable(db_path,th)
print "cpu count: ", mp.cpu_count()
print ("cpu count: ", mp.cpu_count())
parpool = mp.Pool(4)
ucm_result = parpool.imap_unordered(get_mask_parallel, ucm_iter, chunksize=1)
@@ -116,16 +116,16 @@ def process_db_parallel(base_dir, th=0.11):
if res is None:
continue
((mask,area,label),imname) = res
print "got back : ", imname
print ("got back : ", imname)
mask = mask.astype('uint16')
mask_dset = dbo_mask.create_dataset(imname, data=mask)
mask_dset.attrs['area'] = area
mask_dset.attrs['label'] = label
# close the h5 files:
print "closing DB"
print ("closing DB")
dbo.close()
print ">>>> DONE"
print (">>>> DONE")
base_dir = '/home/' # directory containing the ucm.mat, i.e., output of run_ucm.m
invert_font_size.py → prep_scripts/invert_font_size.py
+ 10
- 10
  • View file @ 27d3b941

  • Edit in single-file editor

  • Open in Web IDE


Conflict: This file was renamed differently in the source and target branches. Ask someone with write access to resolve it.
@@ -4,10 +4,10 @@
import pygame
from pygame import freetype
from text_utils import FontState
import os
import numpy as np
import matplotlib.pyplot as plt
import cPickle as cp
import pickle as cp
pygame.init()
@@ -19,21 +19,21 @@ A = np.c_[ys,np.ones_like(ys)]
xs = []
models = {} #linear model
FS = FontState()
#plt.figure()
#plt.hold(True)
for i in xrange(len(FS.fonts)):
print i
font = freetype.Font(FS.fonts[i], size=12)
FONT_LIST = './data/fonts/fontlist.txt'
fonts = [os.path.join('./data/fonts',f.strip()) for f in open(FONT_LIST)]
##plt.hold(True)
for i in range(len(fonts)):
print(fonts[i])
font = freetype.Font(fonts[i], size=12)
h = []
for y in ys:
h.append(font.get_sized_glyph_height(y))
h.append(font.get_sized_glyph_height(int(y)))
h = np.array(h)
m,_,_,_ = np.linalg.lstsq(A,h)
models[font.name] = m
xs.append(h)
with open('font_px2pt.cp','w') as f:
with open('./data/models/font_px2pt.cp','wb') as f:
cp.dump(models,f)
#plt.plot(xs,ys[i])
#plt.show()
prep_scripts/update_freq.py 0 → 100644
+ 21
- 0
  • View file @ 27d3b941

  • Edit in single-file editor

  • Open in Web IDE

from collections import Counter
import pickle
cnt = 0
filename = './data/newsgroup/newsgroup.txt'
with open(filename, 'r') as f:
c = Counter()
for line in f.readlines():
c += Counter(line.strip())
cnt += len(line.strip())
# print c
print(cnt)
for key in c:
c[key] = float(c[key]) / cnt
print(key, c[key])
d = dict(c)
# print d
with open("./data/models/char_freq.cp", 'wb') as f:
pickle.dump(d, f)
\ No newline at end of file
.gitignore
+ 1
- 0
  • View file @ 27d3b941

  • Edit in single-file editor

  • Open in Web IDE


@@ -88,3 +88,4 @@ ENV/
# Rope project settings
.ropeproject
data/
README.md
+ 29
- 0
  • View file @ 27d3b941

  • Edit in single-file editor

  • Open in Web IDE


# SynthText
This a modified version of [Ankush's code](https://github.com/ankush-me/SynthText) for generating synthetic text images which support right-to-left languages such as Persian and Arabic.
As in Persian and Arabic, words are made using connected letters, this code only outputs the word level bounding boxes.
**A sample output of the code**
![Persian Synthetic Scene-Text Samples](sample_fa.png "Persian Synthetic Samples")
## Install the necessary libs and create a conda environment
First install the `fribidi` library
```
sudo apt install libfribidi-dev
```
Then create a conda environment from the `environment.yml` file:
```
conda env create -f environment.yml
```
Activate the environment with the following command:
```
conda activate gentext
```
The rest of the README is from the original repository
------------------
Code for generating synthetic text images as described in ["Synthetic Data for Text Localisation in Natural Images", Ankush Gupta, Andrea Vedaldi, Andrew Zisserman, CVPR 2016](http://www.robots.ox.ac.uk/~vgg/data/scenetext/).
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
2
2 participants
northwill
Administrator
Reference: ankush-me/SynthText!191
Source branch: github/fork/adavoudi/python3

Menu

Explore Projects Groups Snippets