예제 #1
0
async def start():
    try:
        # detect_curling(
        #     "./yolo/data/1.mp4", "./yolo/data/coordinates.txt"
        # )
        draw()
    except:
        return JSONResponse(False, headers=headers)
    return FileResponse("./cutshow/3.jpeg", headers=headers)
예제 #2
0
    def save_model(self, request, obj, form, change):
        obj.user = request.user
        subject = get_subject(obj.content)
        # oss.put_object(obj.image.file.file)
        # 不超过200字
        if len(subject) > 200:
            subject = subject[0:200]

        # 短id
        if not obj.sid:
            obj.sid = short_id.get_short_id()

        obj.subject = subject
        # 处理标签
        tags = obj.tags
        # 自动生成
        if tags is None or tags is "":
            r = analyse.extract_tags(subject, topK=5)
            tags = ",".join(r)

        obj.tags = tags

        # 如果没有封面就生成
        if obj.image.name == '':
            total = Cover.objects.count()
            c = Cover.objects.all()[random.randint(0, total - 1)]
            url = draw.draw(text=obj.title, url=c.image.url, font_size=c.font_size, color=c.color, x=c.x, y=c.y)
            obj.image.name = url
        super(ArticleAdmin, self).save_model(request, obj, form, change)
        cache.delete(cache.CACHE_HOME_KEY)
예제 #3
0
def phase_run(phase_number: int):
    z_init = initial_classes(phase_number)
    G_init = initial_graph(phase_number)
    draw(G_init, z_init)
    G_solution, z_solution = solution(phase_number)
    draw(G_solution, z_solution, "solution")

    z_init = z_solution
    G, z, scores, max_score, G_max, z_max = run(G_init, z_init, max_score=0, after_interaction=False)
    draw(G, z, "before")
    interaction_update(G, z_init, phase_number=phase_number)
    draw(G, z, "update")
    G_out, z_out, scores, max_score, G_max, z_max = run(G_max, z_max, max_score=max_score, after_interaction=True)
    print(scores)
    draw(G_max, z_max, "solution")
    print(f"Score output {score(G_max, z_max)}")
    print(f"Score solution {score(G_solution, z_solution)}")
    measure_run(G_max, G_solution, phase_number)
예제 #4
0
파일: training.py 프로젝트: qunox/Totopos
    def __init__(self , config):

        self.logger = logging.getLogger('sublog')
        self.config_f = config
        self.mainSampleDict = self.config_f.mainSampleDict
        self.mainNodesDict = self.config_f.mainNodesDict
        self.draw_f = draw(self.mainNodesDict , self.mainSampleDict , self.config_f)

        if self.config_f.nodesWidth <= self.config_f.nodesHeight:
            self.config_f.effRadius = self.config_f.initialRadius * self.config_f.nodesWidth
        else:
            self.config_f.effRadius = self.config_f.initialRadius * self.config_f.nodesHeight

        self.LinearRadiusGradient = (1 - self.config_f.effRadius) / (0.8*self.config_f.maxTrainingIteration)
예제 #5
0
파일: main.py 프로젝트: DDCHlsq/dataScience
from draw.draw_multi import draw_multi

BORDER=0.5

def getMultiDict(tests=[]):
    res = {}
    for test in tests:
        try:
            res[test]=check(test)
            print(test)
        except:
            if test in res.keys():
                res.pop(test)
    return res

if __name__=='__main__':

    testId = "2209"
    testList = ["2936", "2209", "2390", "2397", "2461","2425"]

    # while True:
    #     res=check(testId)
    #     bad_code=list(filter(lambda x:res[x]>BORDER,res))
    #     print(len(bad_code))
    #     print(bad_code)
    #     testId = input()

    draw(check(testId),testId)
    tests=getMultiDict(testList)
    print(tests)
    draw_multi(tests)
예제 #6
0
from data.initial_data import initial_point
from draw.draw import draw
from non_reversible_mcmc.mcmc_search_and_score import SearchScore, Point, Step
import os

ARTICLE_DIR = '/home/antonina/learning_casual/IEEEtran/graph'

p_init = initial_point(3)
ss = SearchScore(alpha=1,
                 beta=(1, 1),
                 step=Step,
                 max_epochs=1,
                 p_init=p_init,
                 phase_number=3,
                 after_interaction=False)
_score = ss.score(p_init)
draw(p_init.G,
     p_init.z,
     title='',
     save=os.path.join(ARTICLE_DIR, 'initial_all.png'))
예제 #7
0
from data.initial_data import solution
from draw.draw import draw
from non_reversible_mcmc.mcmc_search_and_score import SearchScore
from non_reversible_mcmc.point import Point
from non_reversible_mcmc.step_methods import Step

if __name__ == '__main__':
    G, z = solution(phase=3)
    point = Point(G, z)
    draw(G, z)
    ss = SearchScore(alpha=1,
                     beta=(1, 1),
                     step_class=Step,
                     max_epochs=1,
                     p_init=Point(G, z))
    ss.score(point)
예제 #8
0
파일: test.py 프로젝트: 750104472/blog
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myblog.settings")
django.setup()

from draw import draw
from article.models import Cover, Article
import random
from django.db import models

all = Article.objects.all()

total = Cover.objects.count()

for item in all:
    # if item.image != '':
    #     continue
    c = Cover.objects.all()[random.randint(0, total - 1)]
    url = draw.draw(text=item.title,
                    url=c.image.url,
                    font_size=c.font_size,
                    color=c.color,
                    x=c.x,
                    y=c.y)
    item.image.name = url
    print(url)
    item.save()

# all = Cover.objects.all()
# for index, item in enumerate(all):
#     draw.draw(item, name=index, font_size=item.font_size, color=item.color, x=item.x, y=item.y)
#     print(item, index)